Home Basics I Basics II Commands I vi Editor Commands II Permissions
Networking Archiving File System Sys. Admin More Info Bulletin Board Contact Us


Linux Commands

OK, in this lesson we are going to learn many common UNIX commands. You are going to learn by doing. Make sure you answer the questions as you go along.

  1. Login to your practice account. If you forgot how to do this, go back to Lesson One.
  2. Do an "ls" to see the files you have in your directory.
  3. Type in "pwd" . What do you see?
  4. Type in "uname -a" . What do you see?
  5. Now, type in "clear" . What happens?
  6. Please type in "man pwd" . What do you see? Use the spacebar to scroll through, and press "q" to quit.
  7. Now type in "mkdir" . What happens?
  8. Now type "mkdir labpractice"
  9. Type "ls". Now what do you see?
  10. Type "cd labpractice".
  11. Type "pwd". Where are you now?
  12. Type "touch lab3file".
  13. Type "ls". What do you see now?
  14. Type ls with an -al switch. What do you see? Can you tell how big the file is?
  15. Type "cp lab3file lab3file2" . Again, type "ls". What do you see now?
  16. Type "rm lab3file2". Again, type "ls". What is there?
  17. Repeat the "rm" command on the other file. Do an "ls -al" to see what's in the directory. Hint: It should be empty.
  18. Type in "cd .." Take note. That is cd plus a space, plus two periods. This should bring you back up one directory and put you in your home directory.
  19. Type "ls" and then type "rm labpractice" . What happens?
  20. Type "rm -r labpractice" and then do an "ls". What happens this time?
  21. Type "mkdir public_html".
  22. Type "mkdir Desktop".
  23. Type "cd Desktop", and then type "touch file1 file2 file3 file4 file5".
  24. You are done.

The following is a list of this lesson's commands. You can use this as a reference for the practice lab.

ls Lists files. The equivalent of "dir" in DOS. Common switches are -al which will list all files with a long description, including their permissions, size, and datestamp. You can also type in ls -al followed by a specific filename to learn information about that specific file. This is helpful if you have many files within a directory and you only want information on one of them. You can even use wildcards. For example, ls *.html show only files with extension .html
uname -a Show info about current machine and operative system
pwd Print Working Directory. Wonder which directory you're currently in? This reveals full path.
clear clear the screen
touch touch filename. If filename doesn't exist it gets created (0 byte). If filename already exists, touch alters its timestamp to the current time. Please note, in UNIX we can not easily name files with spaces in them, so words should use underscores or a capital letter to separate them. For example, touch my file will not work. You must write either touch myFile or touch my_file . This applies to creating directories as well.
mkdir makes a directory. You can put files in a directory :)
rmdir removes an empty directory. If it is not empty, you can use rm -rf instead.
rm removes files. You can use it with wildcards too. For example rm -f *.html will remove all html files in the directory. You can use it to remove a directory with an -rf switch. However, this is not the ideal way to remove directories.
cp cp originalFile newFile Creates a copy of the first file having the name of the second. If the paths are not specificied, then cp assumes you mean the current working directory. You can also copy a file to another location. For example,
cp OriginalFile /home/someDirectory/newFile
will copy a file from the current directory to another directory with "NewFile" as it's name. If no name is specified, and you are copying the file to another directory, then the original filename will be used.

Now for the Lab Assignment:

Log on to your UNIX account. Make a directory named using your first and last name. Inside that directory, create 2 files, one for your first name and one using your second name. Issue a command to see these files' time stamps. After that, update the timestamps.

NEXT LESSON

If you do not have your own linux server, you can get a shell account through us and learn UNIX quickly.


Home Basics I Basics II Commands I vi Editor Commands II Permissions
Networking Archiving File System Sys. Admin More Info Bulletin Board Contact Us
© Copyright 2001-2008. All rights reserved.