Shell Basics
From Campus Web Server Help
UGA Webhosting is built on Linux servers. However, you do not have to have an extensive knowledge of Linux to manage your site from a command-line. The subset of commands listed below should provide an adequate base for most of the tasks you will need to perform. You enter these commands after logging in with your username and password using SSH.
Contents |
Management Commands
Commands, file names, and directory names, are case sensitive! If a file name contains uppercase characters, the file name should be typed with uppercase characters. The command ls should be entered in all lowercase characters. Typing LS is not the same as typing ls.
Detailed Command Help
Command: man command
Get more information on any command, including the ones listed below. Example:
man ls
Information about the ls command will be displayed. To page through the information, press the space bar. Type q to quit man.
Password
Command: passwd
Change your login password.
Example:
passwd
You will be prompted for your old password, which is the password you are currently using. After typing in your old password and pressing RETURN or ENTER, you will be prompted for a new password. Using the computer-generated, suggested password is recommended. You will asked to re-enter the password for verification.
File Listing
Command: ls
List the files and subdirectories in the current directory.
Example:
ls
A list of files and subdirectories will be displayed.
An example listing:
docs.html home.htm lans sites helpdesk images msd test
Example:
ls -la
The addition of -la will display the list of files in "long" form with "all" files (including the ones that start with a period).
An example listing:
drwxr-x--- 27 eits 1024 Jun 21 08:22 . drwxr-xr-x 6 eits 512 Jun 21 08:22 .. -rw-r--r-- 1 eits 1241 May 15 16:11 docs.html drwxr-x--- 9 helpdesk 1024 Jun 13 16:02 helpdesk -rw-r--r-- 1 eits 5448 Jun 9 15:27 home.htm drwxr-xr-x 9 hostsys 512 Jun 20 16:14 images drwxr-x--x 6 lans 1024 Jun 14 23:28 lans drwxr-x--x 6 lans 1024 Jun 14 23:28 msd drwxr-x--x 6 lans 1024 Jun 14 23:28 sites drwxr-x--x 6 lans 1024 Jun 14 23:28 test
All of the items in this list with a d in the first column are directories. The items with a "-" in the first column are files.
Show the Current Directory
Command: pwd
Show the current directory
Example:
pwd
The current directory you are in will be displayed. If you issue this command after you log in and before changing to another directory (see the cd command below), your "home" directory will be displayed. Your home directory is the one you are automatically placed into when you log in.
Create a Directory
Command: mkdir "directory"
Make a new directory
Example:
mkdir "public_html"
This will create a new directory called "public_html" in the current directory.
Change Directories
Command: cd "directory"
Change to a different directory.
Example:
cd "public_html"
This will make the current directory "public_html". You can also type the cd command without a directory and press RETURN to change to your "home" directory (e.g. the directory you are automatically placed into when you first log in. Since you will be doing most of your work in the public_html directory, you can always change to that directory with the command: cd ~/public_html.
Move Files/Directories
Command: mv "filea" "fileb"
Move or rename files or directories.
Example of moving/renaming a file:
mv home.htm home.old.htm
This command will rename the file "home.htm" to "home.old.htm". Directories can be moved or renamed the same may.
Example of moving and renaming a file in one directory to a different directory:
mv staff.html people/staff.html
This command will move the file "staff.html" in the current directory to the directory "people" as the file "staff.html"
Remove Files
Command: rm "file"
Remove (delete) a file.
Example:
rm home.old.html
This command will delete the file "home.old.html"
Remove Directories
Command: rmdir "directory"
Remove (delete) a directory.
Example:
rmdir may-calendar
This command will remove the directory "may-calendar". The directory must be empty before it can be removed.
View a Text File
Command: less file
View a file using the less command.
Example of viewing a file:
less home.htm
This command will allow you to view the file "home.htm". You can page forward through the file by pressing the space bar. To quit more, type the letter "q".
Edit a File
Command: nano file
Did you know you can log into the server and directly edit the a file? No uploads. Immediate satisfaction!
Edit a file using the nano editor. The nano editor is an alternative to vi. (Many people find nano easier to use than vi.) Help is included. Press Ctrl-g (press the control or Ctrl key and the letter g at the same time).
Example:
nano home.htm
This command will allow you to edit the file "home.htm" or create a new file by this name (if a file by the name specified does not exist).
Logging Out
Command: exit
Log out of the server.
Example:
exit
You may see a brief message that you have logged out. Your session will be terminated.
