Tutorial of Basic Commands in LINUX
 

Introduction
The LINUX environment is text-based, which means you must enter the exact names of commands you want to take place. Each time you press enter in the LINUX environment, you'll receive a prompt. This prompt may differ from person to person, so throughout this tutorial I will use
$ command
to indicate the prompt (given by system) followed by command (typed by you). The LINUX environment is case-sensitive, meaning lowercase alphabetic characters are considered different than their corresponding uppercase alphabetic characters, including within passwords.

Note: Anywhere in the tutorial where you find section#, replace with the course section number in which you are enrolled.

Screenshots may be added in the future.

Logging on to osprey

  1. From a UNF machine, run a telnet client to hostname osprey.unf.edu

  2. * SecureShell
  3. Enter your osprey userID

  4. * your N number
  5. Enter your osprey password
  6. Hit the <Enter> key if the system asks you what terminal type. This means you are accepting the default answer (listed as [vt100]).


Working in the LINUX file system
 

ls, pwd, and cd
  1. Type ls to get a listing of the current directory contents

  2. $ ls
    * Directory names are shown with a trailing / although it is not part of the name itself. Files do not have a /.
    * Executable files (those which can be run as commands) are shown with a trailing * although it is not part of the name. This can be dangerous since the * is also the wildcard meaning "match everything".
  3. Type ls -l to get a listing in long view which shows you file sizes, modification dates and times, owner, and permissions

  4. $ ls -l
  5. Type pwd to see in what directory of the file system you are currently located

  6. $ pwd
    You should still be in your home directory.
  7. Change to the public directory (cd) for this class

  8. $ cd /var/public/cop2220/jgaudry
  9. Type pwd to see you are now located in that directory

  10. $ pwd
  11. Type ls to get a listing of its contents

  12. $ ls
  13. Change to the parent directory

  14. $ cd ..
     
  15. Type ls to get a listing of its contents

  16. $ ls
  17. Change back to your home directory

  18. $ cd
     

    mkdir, touch, and wildcards (? and *)
     

  19. Make a new directory named tempdir

  20. $ mkdir tempdir
    You made it but you didn't enter it yet. You are still in your home directory.
  21. Type ls to get a listing of your home directory and you should see the new directory tempdir/

  22. $ ls
  23. Change into the new directory

  24. $ cd tempdir
  25. Type pwd to see your new location in the file system

  26. $ pwd
  27. Type ls to get a listing

  28. $ ls
    It should be empty.
  29. Make a file called temp using the touch utility

  30. $ touch temp
    Touch either creates a nonexistent file or updates the date/timestamp of an existing file
  31. Type ls to see the contents of the tempdir

  32. $ ls
    and you should see the file temp.
  33. Make another directory within tempdir called tempdir

  34. $ mkdir tempdir
  35. Type pwd to see your current location in the file system

  36. $ pwd
  37. Type ls to see the contents of this directory

  38. $ ls
    and it should show you file temp and directory tempdir/.
  39. Change to the inner tempdir directory

  40. $ cd tempdir
  41. Type pwd to see your current location in the file system

  42. $ pwd
  43. Type ls to see the contents of the current directory. It should be empty

  44. $ ls
  45. Make four files, temp1 temp2 temp50 and notemp, using the touch utility

  46. $ touch temp1
    $ touch temp2
    $ touch temp50
    $ touch notemp
  47. Type ls to see the contents of the current directory

  48. $ ls
    and you should see the new files.
  49. Use wildcards to see filtered lists

  50. $ ls temp?     should show you temp1 and temp2
    $ ls t*        should show you all but notemp
    $ ls *         should show you all
  51. Type cd with no arguments to change back to your home directory (works from anywhere in the file system)

  52. $ cd
  53. Type pwd to see where you are

  54. $ pwd
  55. Type ls with an argument to see contents of other directory/file locations, either relative or absolute

  56. $ ls tempdir
    Keep in mind you are not in the outer tempdir. You're still in the home directory, but you can see the contents of any directory for which you have permission.
  57. Type ls to see the contents of the inner tempdir from your current home directory location

  58. $ ls tempdir/tempdir
  59. Change to the inner tempdir

  60. $ cd tempdir/tempdir
  61. Type pwd to see your location

  62. $ pwd
  63. Type ls to see the contents of the current directory

  64. $ ls
  65. Back up to the parent directory

  66. $ cd ..
  67. Type pwd to see your location

  68. $ pwd
  69. Type ls to see the contents of the current directory

  70. $ ls
     

    rm and rmdir
     

  71. Try to delete the inner tempdir directory

  72. $ rmdir tempdir
    It should tell you that it cannot delete because that directory isn't empty.
  73. Type ls to see the contents of the current directory

  74. $ ls
  75. From the current location (outer tempdir), delete all files within the inner tempdir

  76. $ rm tempdir/*
    BE VERY CAREFUL NEVER TO REMOVE ALL FILES IN CURRENT DIRECTORY ($ rm *) UNLESS YOU ARE ABSOLUTELY SURE OF WHERE YOU ARE LOCATED AND WHAT YOU ARE DOING. YOU MAY ACCIDENTALLY REMOVE OPERATING SYSTEM FILES OR YOUR C SOURCE CODE.
  77. Type ls to see the contents of the current directory

  78. $ ls
  79. Type ls with an argument to see the contents of the inner tempdir

  80. $ ls tempdir
    It should be empty
  81. Delete the inner tempdir

  82. $ rmdir tempdir
    Works this time.
  83. Type ls to see the contents of the current directory

  84. $ ls
  85. Back up to the parent directory (the home directory)

  86. $ cd .. or in this case $ cd
  87. Type ls to see the contents of the current directory

  88. $ ls
    Outer tempdir still exists and is located in the home dir.
     

    cp and mv
     

  89. Create a new file temp3 in the home dir

  90. $ touch temp3
  91. Copy it to the tempdir

  92. $ cp temp3 tempdir
  93. Type ls to see the contents of the current directory

  94. $ ls
    File temp3 still there.
  95. Type ls with an argument to see the contents of the outer (now only) tempdir

  96. $ ls tempdir
    File temp3 also there.
  97. Copy temp3 from the homedir to the tempdir and give it a new name

  98. $ cp temp3 tempdir/newtemp3
  99. Type ls with an argument to see the contents of tempdir

  100. $ ls tempdir
  101. Move temp3 to the tempdir and give it a new name

  102. $ mv temp3 tempdir/movedtemp3
  103. Type ls to see the contents of the current directory

  104. $ ls
    File temp3 is gone
  105. Type ls with an argument to see the contents of tempdir

  106. $ ls tempdir
  107. Rename a file within tempdir from the home directory

  108. $ mv tempdir/temp3 tempdir/renamed
  109. Type ls with an argument to see the contents of tempdir

  110. $ ls tempdir
  111. Change into tempdir

  112. $ cd tempdir
  113. Type pwd to see your location

  114. $ pwd
  115. Type ls to see the contents of the current directory

  116. $ ls
  117. Rename a file to an existing filename

  118. $ mv renamed temp
  119. Type ls to see the contents of the current directory

  120. $ ls
    Shows renamed is gone and temp still there, but actually original temp was deleted and file renamed was changed to filename temp.


Displaying files

  1. Copy the file mary.txt from the public directory to your current location (should be tempdir)

  2. $ cp /var/public/cop2220/jgaudry/mary.txt .
  3. Make a subdirectory called myfiles

  4. $ mkdir myfiles
  5. Copy the file humpty.txt from the public directory to myfiles

  6. $ cp /var/public/cop2220/jgaudry/humpty.txt myfiles
  7. Type ls to see the contents of the current directory

  8. $ ls
  9. Type ls with an argument to see the contents of myfiles
    $ ls myfiles
  10. Display the contents of mary.txt

  11. $ cat mary.txt
  12. Display the contents of humpty.txt

  13. $ cat myfiles/humpty.txt
    Scrolls off the screen because is bigger than one screen
  14. Try again using a different display tool

  15. $ less myfiles/humpty.txt
    Use the space bar to see subsequent screens, use the j and k keys to move down and up a line at a time, respectively, use q to quit


Changing permissions

  1. Display a listing of the current directory in long form

  2. $ ls -l
    Note the permissions on the files and directories
  3. Remove all permissions (read, write, and execute) for group and other users to the file mary.txt

  4. $ chmod go-rwx mary.txt
  5. Display a listing of the current directory in long form

  6. $ ls -l
  7. Display a listing of the myfiles subdirectory in long form

  8. $ ls -l myfiles
  9. Remove read permission for group and other on all files/subdirs in myfiles

  10. $ chmod go-r myfiles/*
  11. Display a listing of the current directory in long form

  12. $ ls -l
    Didn't change the permissions on myfiles itself, just the files/dirs in it
  13. Display a listing of the myfiles subdirectory in long form

  14. $ ls -l myfiles
    See?
  15. Add write permission for other on myfiles

  16. $ chmod o+w myfiles
  17. Display a listing of the current directory in long form

  18. $ ls -l
    Changed the permissions on myfiles itself...
  19. Display a listing of the myfiles subdirectory in long form

  20. $ ls -l myfiles
    ...but not on its contents


Compiling, testing, and turning in C source electronically

  1. Change to the public directory

  2. $ cd /var/public/cop2220/jgaudry
  3. Display a listing

  4. $ ls
    You should see the files you copied before
  5. Copy the file mary.c to your tempdir

  6. $ cp mary.c ~/tempdir OR $ cp mary.c /home/<lastinitial>/<userID>/tempdir
    Note the spaces separating command and arguments
  7. Change back to your tempdir

  8. $ cd ~/tempdir OR $ cd then $ cd tempdir
  9. Display a listing

  10. $ ls
  11. Display the contents of the file

  12. $ cat mary.c
    It's a C source code file.
  13. Compile the source code

  14. $ gcc mary.c
  15. Display a listing

  16. $ ls
    The compiler created the executable file a.out
  17. Run the program to make sure it executes properly

  18. $ ./a.out
    It should display the nursery rhyme.
  19. Turn in the C source to the assignment description jgaudry.tutorial

  20. $ turnin mary.c jgaudry.tutorial
    Note you are NOT turning in the executable, you are turning in the source.
  21. Check that you turned it in successfully

  22. $ turnin -c jgaudry.tutorial
  23. Display a long listing

  24. $ ls -l
    Make sure the byte size of mary.c is the same size as what turnin -c told you was turned in.


Creating a text file (C source code is text)

  1. Create a new file using pico

  2. $ pico
    Note the commands listed at the bottom of the screen. The ^ symbol means hold down the control key <Ctrl> and press the appropriate letter.
  3. Type in some information into the file.
  4. Save the file using the command ^O Write Out (hold <Ctrl> and press O).
  5. It prompts you for a filename. Type mytext and press <Enter>.
  6. Type some more information into the file.
  7. Exit pico using the command ^X Exit (hold <Ctrl> and press X).
  8. It asks you whether you want to save changes. Type Y for yes (choices listed at bottom).
  9. It asks you for the filename and puts mytext in as the default filename. Press <Enter>. You're back at the LINUX prompt.
  10. Display a listing

  11. $ ls
    and you see your file mytext
  12. Display the file

  13. $ cat mytext
  14. Edit the file using pico

  15. $ pico mytext
    and the editor starts with the file mytext loaded.
  16. Exit the editor with the command ^X.


Creating an email message and attaching a file

  1. Start the email reader

  2. $ pine
  3. At the bottom of the screen, it may ask you whether you want to run a tutorial or move your saved mail to a different name. Answer however you would like.

  4. The main menu should display.
  5. To read your new messages, choose I for Inbox (or use the arrow keys).

  6. Anytime you want to go back to the main menu, press M (if you're not in edit mode).
  7. Compose a new message by pressing C from the main menu.
    Note the commands listed at the bottom of the screen are similar to pico.
  8. Put in jgaudry as the recipient and press <Enter>.
  9. Press <Enter> to skip the cc: field
  10. To attach a file, use the command ^J Attach.

  11. Then either type the filename (relative path from home directory no matter where current location OR absolute path) or use the command ^T to go to a file listing of your home directory. We'll do the latter.
  12. Go to tempdir with the arrow keys and press <Enter>, then go to myfiles with the arrow keys and press <Enter>, then go to humpty.txt and press <Enter> to attach the file.
  13. Press <Enter> to skip the Attachment Comment.
    The file is correctly attached to the email.
  14. Press <Enter> to move to the Subject line.
  15. Type Humpty and press <Enter>
  16. Type me a message.
  17. Use the command ^X to send (NOTE it is to send, not exit as in pico).
  18. Press Y to confirm the send.
  19. Press L to view your folder list.
  20. Choose sent-mail with the arrow keys and press <Enter>.

  21. Note the last message sent is to me on the current date.
  22. Press M to go the main menu.
  23. Press Q to quit pine.

  24. You're back at a prompt.


Viewing online help files

  1. Get online help for the pwd command

  2. $ man pwd
    Man uses the less program to display help files, so press q to quit less.


Cleaning up

  1. Display current location

  2. $ pwd
    It should be tempdir
  3. Remove contents of myfiles

  4. $ rm myfiles/*
  5. Remove myfiles directory

  6. $ rmdir myfiles
  7. Back up to the parent (the home directory)

  8. $ cd ..     or in this case     $ cd
  9. Remove contents of tempdir

  10. $ rm tempdir/*
  11. Remove tempdir directory

  12. $ rmdir tempdir


Logging off

  1. Log off the system

  2. $ exit