tux penguin

Linux commands

adduser
adduser adds a new user. (see useradd)
sudo adduser jo creates a new user jo.

alias
alias allows you to define short version of command you commanly use.
alias ll='ls -lAh' will run ls with the flags l, A and h.

apt-get
apt-get manages software packages.
sudo apt-get update retrieves updated deails of available packages from software repositories.
sudo apt-get upgrade updates currently installed software.
sudo apt-get install abc install package abc.
sudo apt-get clean clears out the archive, without affecting the installed software.

apt-cache
apt-cache allow seaches of the software packages available.
apt-cache search games searches for software described as games.
apt-get show bsdganes show details of specific software.

cat
cat concatenates files and outputs the results.
cat a b display of the contents of a then b.s

cd
cd changes the current directory.
cd changes the current directory to the user's home directory.
cd ~ changes the current directory to the user's home directory.
cd - changes the current directory to the previous dirctory.
cd a changes the current directory to a.

cp
cp copies files and directories.
cp a b copies file a to file b.

dd
dd creates an image file from a device or copies an image file to a device.
This should be used with extreme care because it can overwrite the entire contents of a device with no warnings.
sudo dd if=/dev/sdb of=b.img copies the contents of /dev/sdb to b.img.
sudo dd if=b.img of=/dev/sdb copies the contents of b.img to /dev/sdb.

df
df shows the amount of free disk space.
df shows the free space on all drives.
df -h shows the free space on all drives in an easier to read format.

echo
echo outputs whatever text in quotes follws it.
echo "abc" outputs abc.
echo -e "abc\n" translates escape characters inside the quotes.

export
export set the value of a variable for the life of the current session.
export VAR1="abc" sts VAR1 to abc.

grep
grep searches for lines with a given text or pattern in a file.
grep xyz abc finds lines containing xyz in the file abc.

head
head shows the the first lines of a file.
head abc shows the first lines of abc.
head -n 5 abc shows the first 5 lines of abc.

ifdown
ifdown takess down network interfaces.
ifdown wlan0 takess down the wireless network interface.

ifup
if brings up network interfaces.
ifup waln0 brings up the wireless network interfaces.

ls
ls lists files and directories.
ls lists file in the current directory.
ls a* lists file in the current directory beginning with "a".
ls -a lists ALL files in the current directory including those start with ".".
ls -A lists ALL files in the current directory including those start with "." except "." and "..".
ls -l lists files in the current directory with each file on a separate line.
ls -h shows file sizes in human readable format.
ls -R lists files in the current directory and subdirectories.

man
man displays the online manual.
man ls displays the manual entry for the ls command.

mkdir
mkdir creates a directory.
mkdir a creates directory a.

more
more displays the contents of a file one page at a time.
more a displays the contents of file a.

mount
mount inserts a storage device at a specified mounting directory in the Linux file system.
mount /dev/sdc1 /mnt attaches the contents of the sdc1 device to the /mnt directory.

passwd
passwd changes a users password
passwd changes the current user's password.
sudo passwd jo changes jo's password.

pwd
show the current directory.

reboot
reboots the machine.

rm
rm removes (i.e. deletes) files.
rm a removes file or directory a.
rm -r a removes directory a and all subdirectories and files.
rm -rf a removes directory a and all subdirectories and files without prompting for confirmations.

sort
sort sort lines into alphabetical order.
cat a | sort sorts the lines in file a.
cat a | sort -f sorts the lines in file a ignoring case

startx
Starts the graphical desktop based on X Window system.

su
su changes the current user.
su - jo chnage the current user to jo.

sudo
The sudo command runs the next command on the command line with superuser privileges e.g.:
sudo apt-get update
You will prompted for the root password unless you have used sudo recently.

tail
head shows the the last lines of a file.
tail abc shows the last lines of abc.
tail -n 5 abc shows the last 5 lines of abc.

top
top displays the current state of the system and running processes.
This is useful for finding the process id (PID) of processes e.g. to kill them.

unalis
unalis removes a previously defined alias (see alias). unalias ll removes the ll alias.

uniq
uniq eliminates duplicate lines.
cat abc | uniq shows unique line in abc.

useradd
useradd adds a new user.(see adduser)
sudo useradd jo creates a new user jo.

wc
wc displays the number lines, words and bytes in a file.
wc -l abc shows only the numbers of lines in abc.
wc -w abc shows only the numbers of words in abc.
wc -m abc shows only the numbers of characters in abc.
wc -c abc shows only the numbers of bytes in abc.

whoami
whoami displays the identity of the current use.
This is useful if the current user has been changed using su.

Home page