Linux Commands

 Introduction | Useful Links | Hosting Plans | Resellers | Dedicated Server | Buy Instant SSL Cert. | SSL Cert Information | Domain Registration | Web Site Design | Contact Us | Help & Support | Terms & Conditions| Glossary of terms | Home |

To help you to start using telnet, we have provided a list of the most common / useful commands available for basic administration. Remember that you must telnet into your account  from your control panel "CPanel before these commands can be issued.
cd [dir] Change the current working directory to dir

To change the current working directory to /www/cgi-bin  
$ cd /www/cgi-bin

chmod mode file Change the access permissions of FILE to MODE. 

To set the permissions for the index.html to rwxr-xr-x 
<>$ chmod 755 index.html 

For more details on modes and permissions refer to the section on Linux permissions

cp source dest Copy a file or directory from the SOURCE location to the DEST location. 

$ cp docs/index.html vhtdocs/list.html 
copies index.html in the docs directory into the vhtdocs directory but with the filename list.html

$ cp docs/index.html vhtdocs 
copies index.html in the docs directory into the vhtdocs directory preserving the filename.

cat file Read one or more files and print them to standard output 

To output the contents of readme.txt to the screen 
$ cat readme.txt 

To append the contents of readme.txt to readme.1st 
$ cat readme.txt >> readme.1st

ls name List the contents of directory NAME or display information about the file NAME. 

To list the contents of /www/cgi-bin 
$ ls /www/cgi-bin 

To list the contents of /www/cgi-bin, including hidden files, in long format 
$ ls -al /www/cgi-bin

mv source dest If DEST is a directory then move the file or directory SOURCE into the directory DEST. 
If DEST is not a directory then rename the file or directory SOURCE to DEST. 

To rename readme.1st to readme.txt 
$ mv readme.1st readme.txt 

To move docs/index.html to the directory vhtdocs 
$ mv docs/index.html vhtdocs

mkdir dir Create a new directory called DIR 

To create the directory test in the current working directory 
$ mkdir test

less file less is a filter for paging through text one screenful at a time. 

To view the Apache webserver error log 
$ less /var/log/httpd/error_log 

Press key Q to exit the pager.

rm name Delete a file or directory called NAME. 

To delete the file readme.1st 
$ rm readme.1st 

To delete the empty directory temp 
$ rm temp 

To delete a non-empty directory called temp 
$ rm -r temp 

To delete a file or directory without being prompted (use with caution) 
$ rm -f temp

tail file Output the last part of files 

To display the last ten lines of /var/log/httpd/error_log 
$ tail -f /var/log/httpd/error_log 

To display the last 100 lines of /var/log/httpd/access_log 
$ tail -n 100 -f /var/log/httpd/error_log

su user Run a command with substitute user and group id. This command is typically used to take on the persona of another user. The user's password is required.

To take on the persona of the web user
$ su web

chown user[.group] file Change the user and group ownership of files.

To make the file index.html owned by the user web
$ chown web index.html

To make the file index.html owned by the user web and owned by group admin
$ chown web.admin index.html

To change the ownership of a directory and all files within it to user admin and group web
$ chown -R admin.web /home/httpd/docs

chgrp group file Change the group ownership of files.

This works similarly to chown however only the group ownership can be changes

To make the file index.html owned by group web
$ chgrp web index.html

chmod mode file Change the access permissions of files.

To make the script test.sh owner read/write/execute, group read/execute and world read/execute:
$ chmod 0755 test.sh

top Provide an ongoing look at the most CPU-intentive processes on the Virtual Server.

Usage:
$ top

ps options Reports the status of processes

To list all processes running on the virtual server
$ ps a

To list all processes running, including memory and CPU usage statistics:
$ ps au

kill -signal pid kills a specific process, the process ID can be ascertained from ps or top

Send the process PID the signal SIGNAL. PID is the identification number of the process and SIGNAL is a number mapped to a signal name.

To retrieve a list of available signal numbers:
$ kill -l

To send an interrupt signal (SIGINT) to process 1852
$ kill -2 1852

pwd Print the current working directory

$ pwd

grep options filename Search one or more files for lines that match a regualr expression

To search for the word rabbit in all .html files in the current directory
$ grep -E "rabbit" *.html

man [section] name Display information from the on-line reference manuals

To display the manpage for the grep command
$ man grep

For names like open there may be many different man pages. Commonly references to man pages are written, "see open(2)". The number in parentheses refers to the section number.

To view man page open(2)
$ man 2 open

To view all man pages associated with open
$ man -a open
and press the Q key to move to the next page.

tar options filename...
tar options directory...
Tar is an archiving program designed to store and extract files from an archive file known as a tarfile.

To create an archive of the conents of the directory /home/httpd
$ tar -cvf web.tar /home/httpd

To extract all files from web.tar into the current working directory
$ tar -xvf web.tar

Additionally the z flag may be applied to compress the tarfile using gzip.
$ tar -czvf web.tar /home/httpd

It is important that the f flag comes last in the options as this takes a filename as a parameter, in the examples above it was web.tar.

To add readme.txt to an already existing tarfile
$ tar -Avf web.tar readme.txt

To extract readme.txt from web.tar
$ tar -xvf web.tar readme.txt

pico file A simple text editor 

To edit index.html in the current working directory
$ pico index.html

vi file A programmers text editor

To edit index.html in the current working directory
$ vi index.html

Upon startup the editor is immediately placed into command mode. To enter text you need to be in insert mode, press key i. To return back to command mode, press the escape key.To exit the vi editor, enter :q in command mode.

nslookup domainname A utility to query Internet domain name servers interactively

To query the nameservers for your-domain.co.uk, returning the corresponding IP address if present.
$ nslookup your-domain.co.uk

whois domainname Search an Internet directory for the person, login, handle or organisation of a domain name.

To retrieve information about the owner of the domain gnome.org
$ whois gnome.org

date print the current date and time

$ date

Resources

Many good texts on Linux exists; a particularly useful book containing a list of available Linux commands is "Linux in a Nutshell" by Ellen Siever, published by O'Reilly & Associates.

<<Home

 Introduction | Useful Links | Hosting Plans | Resellers | Dedicated Server | Buy Instant SSL Cert. | SSL Cert Information | Domain Registration | Web Site Design | Contact Us | Help & Support | Terms & Conditions| Glossary of terms | Home |