Basic commands.


Here is a list of some of the common & widely used commands that you will need. All text in this style is a command to be entered & followed by [ENTER]. For a more detailed description regarding the command options check the man pages (eg. Type man ls to get all the information on the command ls) for that programme, or type ls --help. For more information see the help section.

In the following table "/path" refers to the path to a particular directory, "/path/file" refers to a file at the given path, "name" refers to a file or directory name. Note that the options are to be placed directly after the command, before any path or file details are given. The options belong to that particular command.

LINUX COMMAND OPTIONS COMMENTS
ls -ahl List, the equivalent of the dir command. Displays the contents of the current directory. The options -ahl mean a=all files & directories, h=human readable file sizes (MB & kB), l=long listing with all permissions/attributes.
cd /path   Change to stated directory.
cd ~   Change to "home" directory.
cd /   Change to "root" directory.
cp /path/file /path/file -R Copy file from directory... to .... directory.
rm /path/file -r Remove or delete file. -r = recursive.
mv /path/file /path/file   Move file from one directory to another.
mkdir name   Create a directory called "name" in current directory.
mkdir /path/name   Create a directory called "name" at the path stated.
rmdir name   Remove or delete the directory called name in current directory.
passwd   Change password of current logged in user.
su   To update current login to "super user" i.e. root! Enter root password at the prompt.
du /path -csh Show the amount of disk used by the stated directory. -c= show grand total, -s= summarise, -h= human readable.
df -h Display free space on all mounted devices (HDDs). -h=human readable sizes, MB & kB.
chmod 644 file -R Modify the file permissions on file to 644 i.e. owner: read & write, group: read, others: read. (see permissions)
chown owner:group file -R Change the owner (& group if required) of the file to the stated owner & group. Can also be used with -R.
chgrp new_group file -R Change the group to which the file belongs to new_group. With the -R option you can change recursively all files within a given directory.
tar /path/file -xvf Unpack the tar file.
gzip /path/* file -r Zip all the files found within the /path directory into "file".
gunzip /path/file   Unpack the zip file.
find / -name fetchmail   Find is a search programme. i.e. search through the "root directory" / for the file with the name fetchmail, & display it's location.
ln /path/file file   Link to the file with the target at /path/file into our current directory & call the link file.
man ls   Display the "manual page" for the programme ls.
info ls   Display the "info pages" for the programme ls. This is similar to the man command.
crontab -e -l Setting up the cron daemon to run programmes or scripts at predetermined times. -e= edit cron jobs, -l=list cron jobs.
mkfs.ext2 /dev/fd0   "make file system extended 2" on the device floppy, i.e. format the floppy.
less (many!!) Very useful command for piping, eg. ls -ahl /etc will give you a HUGE list of files, by piping this command through to the less command (ls -ahl /etc | less) you can view this list one "screen" at a time, starting from the first screen.
more   Same as the less command, except you start at the last screen.
head /path/file   Displays by default the first 10 lines of the specified file.
tail /path/file   Displays by default the last 10 lines of the specified file
mount /dev/fd0 /path   Mount the device Floppy into the specified directory
umount /dev/fd0   Unmount the Floppy.
ps -a List all running processes, including PID number (PID refers to the numerical number for a running process. -a =all
pstree -p Lists all running processes, including it's PID, in a hierachle form. -p= show PID number.
kill 1086   Stop the programme with the process number 1086.
netstat -an Used to check the network statistics. Displays (with the -an options) all the ports that are open & also any Ips that are connected to your server.
ping   Check whether a given host is "online". Enter either the hosts IP address or the domain name.
traceroute www.highasakite.net   Used to trace the connection from your machine to the queried host, i.e. traceroute www.highasakite.net. Traceroute displays all the servers that are used to connect you to the host.
nslookup 62.226.127.152   Resolve the IP number into a domain name
ifconfig   Display all your IP addresses, i.e. eth0, eth1, ... , ppp0
who   Displays a list of which user is logged on to your server
fdisk   Like under DOS it's used here to partition HDDs.




back a page    back to main index    forward a page

copyright 2001 Rob Hawke.
rob@highasakite.net