This is an old revision of the document!
Table of Contents
Basic commands for working with Linux
This section covers some very basic commands to efficiently work with a Linux system. They should be available on all standard installations. Although many modern Linux variants offer an advanced GUI, it is advisable to be able to control a Linux system from command line.
Working with Files
ls
lists files in current directory. Use
ls -al
to list all files (including hidden = starting with .) in a long listing.
mkdir
creates a directory. Specify the directory name after the command.
rm
removes files and directories. If directories need to be removed, the
-r
option must be specified. To force operation, add
-f
. The last parameters are the files and directories that are to be deleted. Make sure that there are no wrong directories listed! A call to
rm -rf /
as root is not a good thing.
file
reveals what content type a file is. Use it to test if a file is text, image, binary or whatever.
sudo
starts a process with super user (=root) capabilities. To start a root shell, use
sudo su
. If
sudo
is not installed, use
su
instead. It requires not the current user's password but the root password.
less
helps to look at what a file stores.
cat
reads a file and prints it to
stdout
(the console if invoked as-is.)
locate
locates all files that contain a given string.
grep
searches input for matching lines. To search all files in the current directory (and sub directories), use
grep -r . -e "text"
.
man
shows the manual for some command. Sometimes
info
shows a more detailed documentation.
dmesg
prints kernel messages.
Piping
The output of one command can be piped into the input of another command. This is done by the pipe operator
|
. To search kernel messages for some string, use
dmesg | grep string
.