Ubuntu Linux Absolute Beginners Command Quick Reference
Getting Help
grep texttofind /dir
http://www.ubuntu.com/support
http://ubuntuforums.org/
http://ubuntuguide.org
http://linuxquestions.org/
Pressing F1 will open help for the current application
man any_command
Display the man page for the given
command, e.g. man cp press q to exit
info any_command
As man (may contain more information)
apropos subject
Display related man pages for the given
or man -k subject subject e.g. apropos copy file
V1.52
19/07/2008
Starting with the /dir directory
look for and list files containing the
string texttofind
grep -c findtext files Count how many times findtext
appears in files
Installing Software
Most software installation will require superuser (root) permissions,
precede the following coomands with sudo when required.
Using apt
User/group Admin
adduser name
Create a new user called name
passwd username
Give username a new password
apt-get update
Resynchronize the package index
files from their sources
apt-get install pkg
Install pkg Install multiple
packages by leaving a space
between the names e.g.
apt-get install pkg1 pkg2
usermod -a -G grp user Add user to group grp
groupadd grp
Create group grp
sudo command
Run command as superuser (root)
apt-get remove pkg
Remove pkg as above
sudo -s
Switch to the root (superuser) shell
apt-get upgrade
su username
Switch to username's shell
Upgrade all installed packages to
the latest available version
exit
Stop being the superuser
apt-cache search string Search all available package lists
for names & descriptions
matching string
File Handling
Using dpkg (Installing .deb files)
ls -l
List files in the current directory in long format
ls -F
list files in the current dir and show the file type
dpkg -i file.deb
Install file.deb
ls -a
list all (including hidden) files in the current dir
dpkg -r file.deb
Remove file.deb leaving the
configuration files
cd name
change directory /path/file indicates from
root, path/file indicates relative.
dpkg -P file.deb
Remove file.deb including the
configuration files
cd
change to the current users home directory,
use ~ elsewhere to reference users home dir
dpkg-reconfigure pkg
Reconfigure pkg
rm name
Remove file or directory called name
rm -rf name
Caution Dangerous Command.
Completely remove a directory, all contained
files and subdirectories
Extremely dangerous when used with sudo
Uncompressing files
tar -zxvf arch.tar.gz
Uncompress arch.tar.gz
tar -jxvf arch.tar.bz2
Uncompress arch.tar.bz2
System Information
cp file dest
copy file to dest
mv file dest
Move file to dest
lshw or lspci or
lsusb or report-hw
List Hardware, pci, usb devices add -v
for verbose output (best run as su)
cat file
Display the file
uname -r
Display the kernel version
more file
Display the file one line at a time
dmesg
less file
Display the file use to move & q to exit
Display system diagnostic messages
append >file to output to file
head file
Display the first 10 lines of file
blkid
Display Filesystem UUIDs
head -20 file
Display the first 20 lines of file
tail file
Display the last 10 lines of file
tail -20 file
Display the last 20 lines of file
touch file
Update the access and modification times of
file to the current time.
Finding Files / Text Within Files
find / -name fname
Starting in the root directory, look
for a file named fname
find / -name *fname* Starting in the root directory look
for a file name containing fname
locate fname
Find a file called fname using the
locate command updatedb (next)
should have already been done
updatedb
Create or update the files database
which exec
Display the directory containing the
executable exec e.g
which cp
Starting and Stopping
shutdown -h now
Shutdown now
halt
As above
shutdown -r now
Shutdown and reboot now
reboot
As above
shutdown -r 5
Shutdown and reboot in 5 minutes
startx
Start the X server
Ubuntu Linux Absolute Beginners Command Quick Reference
File Permissions
d
V1.52
19/07/2008
General
Owner
Group
Others
rwx
rwx
rwx
File Type
- = File
d = Directory
l = Link
Appending > filename to any_command will direct the output to
the given filename
Execute (1)
Write (2)
Read (4)
File Permissions are altered by issuing the chmod command
followed by a 3 digit number, the first digit relating to the owner, the
second the group and the third for others. this number is achieved
by adding the values together for the required permissions.
E.g. To add owner RWX, Group RW, Others Read:
chmod 764 filename
Owner = R(4) + W(2) + X(1)
=7
Group = R(4) + W(2)
=6
Others = R(4)
=4
chmod +x file
Make the file executable
chown user file
Change the owner of file to user
chgrp grp file
Change the group of file to grp
Config Files
Make a backup of any file before editing by issuing a
cp origfilename backupfilename command
/etc/profile
System wide environment
variables for all users
/etc/fstab
List of devices and their mount
points
/etc/cron.
hourly daily
weekly monthly
All scripts contained within these
sub directories are run at the set
intervals
crontab -e
Edit current users crontab file
/etc/hosts
A list of all known host names
and IP addresses on the
machine
/boot/grub/menu.lst
The configuration of the grub
boot loader including the items
listed at startup.
Pipes & Chains
cmd1 | cmd2 output of cmd1 is directed to cmd2 (Pipe)
cmd1 && cmd2 Execute cmd1 then cmd2 (Chain)
Operating as root (su)
You can do serious damage to your OS when operating as su. Take
care with what you are doing, ensure you fully understand what the
command you are about to issue will do before hitting the return key
If a permission denied or command not found message is
received after issuing a command then you may need su privileges
to perform the operation. Precede the command with sudo to
continue
Strings
strings containing spaces generally either need to be enclosed in
quotes e.g. text string or the spaces escaped with a \ e.g.
text\ string
Home Folder
Start any path with ~ to reference the current users home folder.
e.g cp /dir/dir/dir/file ~/file
Type cd on its own to return to your home dir.
X-Shortcuts (Desktop)
alt+F2
Display the run dialog
alt+F6
Switch between windows of the
same application
alt+F9
Minimize the current window
alt+F10
Maximize the current window
Ctrl+alt+F?
Switch to another session
Ctrl+alt+Backspace
Restart the X-Server
Ctrl+alt+Cursor
Switch workspace
Ctrl+alt+Tab
Switch between Windows
Compiz-Fusion
ctrl+alt+ or
Rotate cube
ctrl+alt+left click
Free rotate cube
ctrl+alt+
Unfold cube
/etc/dhcp3/dhclient.conf Configuration information for the
DHCP client
shift+alt+
Window picker
alt+tab
Window switch
/etc/X11/xorg.conf
super+tab
Ring switcher
alt+F7
Move window
Slow animations
/etc/resolv.conf
Specifies IP addreses of DNS
servers
Configuration for the X-Server
Processes
ps -e
show all processes running on the system
shift+F10
ps -ef
Show all processes running on the system
with users who own the process
ctrl+alt+D
Show desktop
super+s
Select window
ps -elf
As above showing the 'nice' value
super+t
Tab group
pstree
Show all processes running on the system
in a tree format
super+ or
Change tab
pstree -pu
As above with process IDs (PIDs) and
usernames
super+g
Group windows
super+u
Ungroup windows
kill 12345
Kill the process with the PID of 12345
super+r
Remove group
renice +1 12345
renice the process with id 12345 to a
value of +1 over its current value. +20 =
lowest nice value (will only run when no
other process is active), -20 = highest nice
value. Must be su to reduce the nice value.
super+c
Close group
super+x
Ignore group