A friend wanted a brief, one page quick reference of Bash to help him fix his (frequently) broken system, or at least get him back to a working desktop. He's running Ubuntu, but the basics should be the same. Now its turning into a bit of a project for me....
Before I give it to him, does anyone see any mistakes, or something obvious missing?
Bash quick reference 0.1 An emergency reference for linux.
Most commands work thus: (command) -(option codes) (file name) or /(directory name).
For documentation on each command, use "info (command)", "man (command), or "(command) --help".
Eg:"info ls", or "mv --help". Adding the pipe "|less" can make large documentation more
managable. Eg: "ps --help | less". To exit documentation, press "q", or "(esc)q".
su Switch User. By default this gives administrative permissions to your terminal and applications started
from it. Root directory becomes the root of the partition, as opposed to a normal user whos
root is his directory in the /home folder. Users can only change thier own files, as the
administrator, you can work on all files of all users and the operating system. Eg:"su".
sudo Superuser Do. This gives administrative permission to an application. Eg:"sudo gedit" opens
a gnome text editor with permissions nesessary to change system files.
ls lists the contents of current dir, exept hidden files. "-a" list those too. "-l" adds info
like permissions.Eg: "ls -al"
cd Change directory. With many commands it's best to be in the right directory in order
to work on files within that directory. Eg: "cd Documents". Then using "ls" will show you
the contents of Documents.
Used alone it returns to root of current user. Eg:"cd",
except for su, who may need to use "/", eg:"cd /".
mkdir creates a new folder within the current dir. Use "ls" to confirm. Eg: "mkdir MyMusic"
cp copies a file, eg: "cp song.mp3 MyMusic" would duplicate song.mp3 into
the MyMusic dir.
It can copy whole directories: "cp /home/bob/MyMusic/ /home/fred/MyMusic/" duplicates Bobs'
music folder into Freds.
Note how the use of "/" indicates a folder. It can copy within the same dir if renaming.
eg:"cp song.mp3 song2.mp3".
mv moves or renames files. A rename eg: "mv song.mp3 song3.mp3" will rename the file.
A move eg:"mv song.mp3 MyMusic/" move the file from the current dir into
the MyMusic folder.
A move dir eg: "mv MyMusic/ /home/fred/freds_music/" copies your music folder into Freds
home dir.
rm Permanently deletes a file.
Eg: "rm song.mp3" Deletes that file. "rm *" removes all files in a dir. "rm G*" would remove
every file that starts with G.
rmdir deletes a directory, but only if it is empty. eg: "rm MyMusic", but you would first
"cd MyMusic" and rm the contents.
ps show all active processes with ID numbers of current user. Add -A for all processes of all
users. Eg: "ps -A"
kill kills the named process. Eg:"kill pidgin", or by PID number, Eg:"kill 4022". (You can find
the PID number with ps)
mount opens a partition or device for use. Filesystem and file"-t" must be included.
Eg:"mount -t iso9660 /dev/hdb/cdrom" would mount files(-t) on the CD filesystem(iso9660) of
a typical cdrom drive.
Eg:"mount -t ext2 /dev/sda3 /mnt" would mount files(-t) on a linux filesystem(ext2) on the
satadrive (sda) partition 3.
Eg:"mount -t vfat /dev/hda1 /mnt" mounts files(-t) on a Windows filesysem(vfat) on the IDE
drive(hda) partition 1.
note* many newer linux distros use the sata driver for both Sata and IDE hardrives, and
will show both as sda*.
umount unmounts a drive or partition. Eg:"umount/cdrom" unmounts the cdrom, or "umount/mnt"
unmounts a partition.
gzip compresses files into an archive. It works well with tarballs, eg:"gzip my_music.tar" would
compress your music tarball into "my_music.tar.gz". See also the (g) option of "tar".
tar packs files and directories into a single "tarball" file. Be sure to include the
create option "c", and always end options with the file option(f).
Eg:"tar -cf my_music.tar *.mp3" will create(-c) a file(f),the tarball called "my_music.tar"
with all .mp3 files in the current directory.
"tar" and "gzip" can be used together by using the "z" tar option.
Eg:"tar -czf my_music.tar.gz" would create(c) and compress(z) the file(f) my_music.tar.gz.
It must have the z option and the .gz extension.
To unpack an archive, the options change. (-czf packed it, -zxpf unpacks it)
Eg:"tar -zxpf my_music.tar.gz" will unzip(z), extract(x), preserve(p) permission and date
info, of the files(f). You could unzip without extracting if you still wanted the tarball
by ommiting the (x) option.
startx starts the loading of video and other hardware drivers. If you can't reach desktop, try
this first.
Before xorg 7.3, it was sometimes nessesary to reconfigure xorg;
X -configure | These are some possible commands for reconfigureing
Xorg -configure | xorg. If your kernel boots, but the system hangs or
xorgconfig | crashes before reaching your desktop, then running
dpkg-reconfigure -phigh xserver-xorg | one of these may fix it.
There are a few text editors available to bash. To edit a text file you can either cd to the
directory of the file and open, eg:"nano fstab", or if you know the path use that in the command;
eg:"nano /etc/x11/xorg.conf".
Nano is a text editor with instructions built in. If you're new to it, it helps to know
that the file commands are activated with the Cntl key.
Here are the locations of some commonly needed configuration files:
grub.conf /boot/grub/grub.conf Controls the boot order and boot/kernel options.
Now that UUID is the common format, grub needs the
partition listed as fstab shows it. See fstab.
Also check that the kernel is named the same as the kernel
in /boot.
fstab /etc/fstab Lists the mountpoints of drives.
xorg.conf /etc/x11/xorg.conf is the configuration file specifying what hardware drivers
to load, screen resolution ect...
Note, the original has spacing to make it clearer.......

