The Research Experience for Teachers Program



Download 281.81 Kb.
Page2/2
Date09.06.2018
Size281.81 Kb.
#53739
1   2

Activity Title: “Basic Linux Command Line”

Introduction/Motivation:

Schools tend to use and teach in a Microsoft Windows environment; however, many jobs, and post-secondary schools use and work in Linux and UNIX environments. Necessary skills to navigate, use, and work with Linux and UNIX based systems are needed as many courses in computer science, networking, web administration and others require skills in a Linux and UNIX systems.



Procedure:

Background:

You should understand that Linux runs and starts in levels as it progresses through the boot process. One of these levels is a command line, or console, text only level. This text level is run level 3. The GUI, Graphical User Interface, is run level 5. This lab is focused on using the text based console terminal and basic commands, navigation, and utilities. The command line is available from within the GUI in the form of a terminal session utility. Many versions of Linux are available. Some commands and utilities may not work from version to version. This lab is focused on some fundamental concepts in Linux in general.



Preparation:

You should have access to a Linux computer with a user name, and password for login. This could be a Raspberry Pi, physical workstation, a Windows based computer running a virtual Linux machine, or a bootable live Linux CD/DVD.



Lab Activity:

  1. Boot to your Linux device, and login with your username and password. This lab assumes you have standard access, and not root access at login. Root access means you have full access to the Linux device. During the boot process you may see many services, and hardware devices starting. You will either be prompted with a text based login or a GUI based login depending on how your system is setup. Figure 1 shows a text based login. Enter your username, press enter and then enter your password. (When you enter your password, no characters will appear on the screen for security purposes)




Figure 1 – Login screen on a Unix-like machine

  1. If you logged in through the GUI, browse through the menus until you find TERMINAL. When you find it, click it to open the terminal.




  1. This is the first round of commands at the command line. Try to remember that UNIX systems are case sensitive. That means that “A” does not mean “a”. Another hint for survival. Don’t use spaces when naming things. (Figure 2) Now let’s get started with some commands.



Figure 2 – Screen after the ls command

Command

Example

Description

ls

ls

List items in current directory

cd

cd bar

Navigate to location…Change Directory

cp

cp file1.txt file1.bak

Make a duplicate of the file and keep the original file

mkdir

mkdir bar

Create Directory Bar

rmdir

rmdir bar

Remove Empty Directory bar

rm

rm myfile.txt

Remove or Delete a File

mv

mv filename1 filename2

Move or Rename File, Replaces oldfilename with newfilename

man

man ls

The Man Pages. Online help manual.

more

more index.html

See the contents of a file one page at a time

lpr

lpr index.html

Send a file to the printer

pwd

pwd

Shows present working directory

Type man ls, what does command man do? What did the man command provides you about ls?

Type ls and press enter. What did you see on the screen? Did you know that you can run the ls command with a flag that provides different information?

Then type mkdir test and press enter. What did this command do?

Type ls again, press enter, and you should see a newly created directory. Did you?

Type cd test, press enter and look at the prompt. What did the command cd do? Did your directory change? You can verify by typing the pwd command.



Look at Figure 3 to see if you can see the changes from Figure 2 with these commands.



Figure 3 – A screen after the change to a directory

Type mkdir bar. Then type cd bar. What is your present directory? How would you find that out?

Enter the command pwd. The output on the screen shows your present working directory.

It might look something like /home/username/test/bar

Enter the following command. cd ~ . What did ~ do here? You can try the pwd again to find out.

Now enter cd test/bar.

Let’s create a file quickly without an editor.

Type cat > foo.txt and press enter. A blank line will appear below the command.

Type Hello World on that line, then press enter. To terminate the typing and save whatever you have typed, use the key sequence CTRL-D at the same time. This process creates a file with the contents “Hello World” in it.

Type ls. What happened? Do you see the new file (foot.txt) in that directory?

We haven’t used this cat command before. What does it do? Type man cat to learn more about it.

Press q to leave the man pages.

Type mv foo.txt foonew.txt press enter, and then type ls. What does command mv do?

Now try, cp foonew.txt foo.txt. Type ls again. Explain the difference between mv and cp commands.

Now use your own skills and the man pages to remove the files we created, the directory bar and the directory test. It may be helpful to remember where you are located when trying to do this

Write the list of commands you used to perform the task.

In your terminal session, press the tab key twice. Reply yes to the question. Use q to quit.

What did you find out about your Linux system?



Assessment

Pre-Assessment

  1. What is Linux?

  2. How to make a directory in Linux?

  3. How to change to a specific directory in Linux?

  4. Explain terminal session vs a GUI session?

  5. How can you use the basic Linux commands to check the security of your system?

Results/Conclusions

Using the procedures in this lab could you



  1. Login and use a Linux system

  2. Create a directory, and navigate through them

  3. Use basic commands to view files and connect to the man pages for help

Reference(s):

http://www.washington.edu/computing/unix/unixqr.html



http://en.wikipedia.org/wiki/Linux




Download 281.81 Kb.

Share with your friends:
1   2




The database is protected by copyright ©ininet.org 2024
send message

    Main page