Linux Shortcuts and Commands
Linux Shortcuts and Commands
This is a practical selection of the commands we use most often. Press <Tab> to see the listing of all available
command (on your PATH). On my small home system, it says there are 2595 executables on my PATH. Many
of these "commands" can be accessed from your favourite GUI front-end (probably KDE or Gnome) by
clicking on the right menu or button. They can all be run from the command line. Programs that require
GUI have to be run from a terminal opened under a GUI.
Legend:
<> = single special or function key on the keyboard. For example <Ctrl> indicates the "control" key.
italic = name of the file or variable you probably want to substitute with your own.
fixed width = in-line Linux commands and filenames.
<Ctrl>z whoami
Send the current process to the background. Print my login name.
exit id username
Logout. I can also use logout for the same effect. (If Print user id (uid) and his/her group id (gid),
you have started a second shell, e.g., using bash the effective id (if different than the real id) and the
second shell will be exited and you will be back in supplementary groups.
the first shell, not logged out.)
date uname -a
Print or change the operating system date and time. (= Unix name with option "all") Info on your (local)
E.g., I could change the date and time to 2000-12- server. I can also use guname (in X-window terminal)
31 23:57 using this command: to display the info more nicely.
date 123123572000
To set the hardware (BIOS) clock from the system free
(Linux) clock, use the command (as root) setclock Memory info (in kilobytes).
time df -h
Determine the amount of time that it takes for a (=disk free) Print disk info about all the filesystems
process to complete + other info. Don't confuse it (in human-readable form)
with the date command. E.g. I can find out how long
it takes to display a directory content using: du / -bh | more
time ls (=disk usage) Print detailed disk usage for each
subdirectory starting at the "/" (root) directory (in
who human legible form).
Determine the users logged on the machine.
cat /proc/cpuinfo
rwho -a Cpu info--it show the content of the file cpuinfo.
(=remote who) Determine all users logged on your Note that the files in the /proc directory are not real
network. The rwho service must be enabled for this files--they are hooks to look at information available
command to run. If it isn't, run setup as root to to the kernel.
enable "rwho".
cat /proc/interrupts
finger user_name List the interrupts in use.
System info about a user. Try: finger root
cat /proc/version
last Linux version and other info
Show listing of users last logged-in on your system.
cat /proc/filesystems
history | more Show the types of filesystems currently in use.
Show the last (1000 or so) commands executed
from the command line on the current account. The cat /etc/printcap
"| more" causes the display to stop after each Show the setup of printers.
screenful.
lsmod
uptime (As root. Use /sbin/lsmod to execute this command
Show the amount of time since the last reboot. when you are a non-root user.) Show the kernel
modules currently loaded.
ps
(=print status) List the processes currently run by set|more
the current user. Show the current user environment.
shutdown -h now
pico -w filename
Edit a text file, while disabling the long line wrap. (as root) Shut down the system to a halt. Mostly
Handy for editing configuration files, e.g. /etc/fstab. used for a remote shutdown. Use <Ctrl><Alt><Del>
for a shutdown at the console (which can be done
find / -name "filename" by any user).
Find the file called "filename" on your filesystem
halt
starting the search from the root directory "/". The
reboot
"filename" may contain wildcards (*,?).
(as root, two commands) Halt or reboot the
locate filename
machine. Used for remote shutdown, simpler to
Find the file name of which contains the string type than the previous command.
"filename". Easier and faster than the previous
command but depends on a database that normally Network apps
rebuilds at night.
netscape
./program_name (in X terminal) Run netscape (requires a separate
Run an executable in the current directory, which is Netscape installation). The current versions of
not on your PATH. Netscape (4.x) are known to be big and buggy. They
occasionally crash by vanishing (no other harm
touch filename done). Also, when not connected to the network ,
Change the date/time stamp of the file filename to Netscape likes to refuse to do anything (looks like it
the current time. Create an empty file if the file hanged)-it revives when you connect.
does not exist.
netscape -display host:0.0
(in X terminal) Run netscape on the current
machine and direct the output to machine named mc
"host" display 0 screen 0. Your current machine Launch the "Midnight Commander" file manager
must have a permission to display on the machine (looks like "Norton Commander" for Linux).
"host" (typically given by executing the command
telnet server
xhost current_machine_name in the xterminal of the
machine host. Other X-windows program can be run Connect to another machine using the TELNET
remotely the same way. protocol. Use a remote machine name or IP
address. You will be prompted for your login name
lynx file.html and password--you must have an account on the
View an html file or browse the net from the text remote machine to login. Telnet will connect you to
mode. another machine and let you operate on it as if you
were sitting at its keyboard (almost). Telnet is not
pine very secure--everything you type goes in open text,
A good text-mode mail reader. Another good and even your password!
standard one is elm. Your Netscape mail will read
the mail from your Internet account. pine will let you rlogin server
read the "local" mail, e.g. the mail your son or a (=remote login) Connect to another machine. The
cron process sends to you from a computer on your login name/password from your current session is
home network. The command mail could also be used; if it fails you are prompted for a password.
used for reading/composing mail, but it would be
rsh server
inconvenient--it is meant to be used in scripts for
automation. (=remote shell) Yet another way to connect to a
remote machine. The login name/password from
elm your current session is used; if it fails you are
A good tex-mode mail reader. See the previous prompted for a password.
command.
ftp server
mutt Ftp another machine. (There is also ncftp which adds
A really basic but extremally useful and fast mail extra features and gftp for GUI .) Ftp is good for
reader. copying files to/from a remote machine. Try user
"anonymous" if you don't have an account on the
mail remote server. After connection, use "?" to see the
A basic operating system tool for e-mail. Look at the list of available ftp commands. The essential ftp
previous commands for a better e-mail reader. mail command are: ls (see the files on the remote
is good if you wanted to send an e-mail from a shell system), ASCII, binary (set the file transfer mode to
script. either text or binary, important that you select the
proper one ), get (copy a file from the remote
licq system to the local system), mget (get many files at
(in X term) An icq "instant messaging" client. once), put (copy a file from the local system to the
Another good one is kxicq. Older distributions don't remote system), mput (put many files at once), bye
have an icq client installed, you have to do (disconnect). For automation in a script, you may
download one and install it. want to use ncftpput and ncftpget, for example:
ncftpput -u my_user_name -p my_password -a
talk username1 remote.host.domain remote_dir *local.html
Talk to another user currently logged on your
machine (or use "talk username1@machinename" to talk minicom
to a user on a different computer) . To accept the Minicom program (looks like "Procomm for Linux").
invitation to the conversation, type the command
"talk username2". If somebody is trying to talk to you File (de)compression
and it disrupts your work, your may use the
command "mesg n" to refuse accepting messages. tar -zxvf filename.tar.gz
You may want to use "who" or "rwho" to determine (=tape archiver) Untar a tarred and compressed
the users who are currently logged-in.
tarball (*.tar.gz or *.tgz) that you downloaded from batch any_command
the Internet. Run any command (usually one that is going to take
more time) when the system load is low. I can
tar -xvf filename.tar logout, and the process will keep running.
Untar a tarred but uncompressed tarball (*.tar).
at 17:00
gunzip filename.gz Execute a command at a specified time. You will be
Decompress a zipped file (*.gz" or *.z). Use gzip prompted for the command(s) to run, until you
(also zip or compress) if you wanted to compress files press <Ctrl>d.
to this file format.
kill PID
bunzip2 filename.bz2 Force a process shutdown. First determine the PID
(=big unzip) Decompress a file (*.bz2) zipped with of the process to kill using ps.
bzip2 compression utility. Used for big files.
killall program_name
unzip filename.zip Kill program(s) by name.
Decompress a file (*.zip) zipped with a compression
utility compatible with PKZIP for DOS. xkill
(in an xwindow terminal) Kill a GUI-based program
unarj e filename.arj with mouse. (Point with your mouse cursor at the
Extract the content of an *.arj archive. window of the process you want to kill and click.)
cdparanoia -B "1-"
(CD ripper) Read the contents of an audio CD and
save it into wavefiles in the current directories, one
track per wavefile. The "1-"
means "from track 1 to the last". -B forces putting
each track into a separate file.
playmidi my_file.mid
Play a midi file. playmidi -r my_file.mid will display text
mode effects on the screen.
sox
(argument not given here) Convert from almost any
audio file format to another (but not mp3s). See
man sox.
Graphics-related commands
kghostview my_file.ps
Display a postscript file on screen. I can also use the
older-looking ghostview or gv for the same end effect.
gimp
(in X terminal) A humble looking but very powerful
image processor. Takes some learning to use, but it
is great for artists, there is almost nothing you can't
do with gimp. Use your mouse right button to get
local menus, and learn how to use layers. Save your
file in the native gimp file format *.xcf (to preserve
layers) and only then flatten it and save as png (or
whatever). There is a large user manual /usr/
gphoto
(in X terminal) Powerful photo editor.