This section gives insight into the most important commands of your SuSE Linux system. Along with the individual commands, parameters are listed and, where appropriate, a typical sample application is introduced.
To learn more about the various commands, it is usually possibleto get additional information with the man program followed by the name of the command, for example, man ls.
In these manual pages, move up and down with PgUp and PgDn and move between the beginning and the end of a document with Home and End. End this viewing mode by pressing Q. Learn more about the man command itself with man.
There are many more commands than listed in this chapter. For information about other commands or more detailed information, we recommend the O'Reilly publication Linux in a Nutshell. In the following overview, the individual command elements are written in different typefaces.
The actual command is always printed as command. Without this, nothing can function.
Options without which the respective program cannot function are printed in italics.
Further details, like file names, which must be passed to a command for correct functioning, are written in the Courier font.
Specifications or parameters that are not required are placed in [brackets].
Adjust possible specifications to your needs. It makes no sense to write ls file(s), if no file named file(s) actually exists. You can usually combine several parameters simply by writing ls -la instead of ls -l -a.
If you run ls in its bare form — without any arguments — the program will list the contents of the current working directory in short form.
detailed list
displays hidden files
Copies sourcefile to targetfile.
Waits for confirmation, if necessary, before an existing targetfile is overwritten
Copies recursively (includes subdirectories)
Copies sourcefile to targetfile then deletes the original sourcefile.
Creates a backup copy of the sourcefile before moving
Waits for confirmation, if necessary, before an existing targetfile is overwritten
Removes the specified file(s) from the file system. Directories are not removed by rm, except when the -r option is specified to force this behavior.
Also delete existing subdirectories
Waits for confirmation before deleting each file
Creates an internal link from the sourcefile to the targetfile, under a different name. Normally such a link points directly to the sourcefile on one and the same file system. However, if ln is executed with the -s option, it creates a symbolic link that only points to the directory where the sourcefile is located, which makes it possible to link across file systems.
Creates a symbolic link
Changes the current (working) directory. A bare cd (with no arguments) changes to the home directory.
Creates a new directory.
Deletes the specified directory, provided that no files remain in it.
Transfers the ownership of a file to the user with the specified username.
Changes files and directories in all subdirectories.
Transfers the group ownership of a given file to the group with the specified groupname. The file owner can only change group ownership if he is a member of both the existing and the new group.
Changes file permissions.
The mode parameter has three parts: group, access, and access type. group accepts the following characters:
user
group
others
For access, access is granted by the + symbol and denied by the - symbol.
The access type is controlled by the following options:
read
write
eXecute — for executing files or changing to the directory
Set uid bit — the application or program is started as if it were being started by the owner of the file.
This program compresses the contents of files, using complex mathematical algorithms. Files compressed in this way are given the extension .gz and normally need to be uncompressed before they can be used again. To compress several files at once, or even entire directories, you can use the tar command.
decompresses the packed gzip files so they return to their original size and can be processed normally (like the command gunzip).
The tar puts one file or (usually) several files into one archive, which may optionally be compressed.
tar is a quite complex command with a number of options available. The most frequently used options are:
Writes the output to a file and not to the screen as is usually the case
Creates a new tar archive
Adds files to an existing archive
Outputs the contents of an archive
Adds files, but only if they are newer than the files already contained in the archive
Unpacks files from an archive (extraction)
Packs the resulting archive with gzip
Compress the resulting archive with bzip2
List files processed
The archive files created by tar end with .tar. If the tar archive was also compressed using gzip, the ending is .tgz or .tar.gz. If it was compressed using bzip2, .tar.bz2.
Application examples can be found in the section called “Archives and Data Compression”.
The locate command allows you to find out where a specific file is located. You can also use wild cards to specify file names. The program works very quickly because it uses a database specifically created for the purpose (rather than searching through the whole file system). This very fact, however, also results in a major drawback: locate is unable to find any files created after the latest update of its database.
The database can be generated by root with updatedb.
This command performs an update of the database used by locate. To include files in all existing directories, run the program as root. It also makes sense to place it in the background by appending an ampersand (&), so you can immediately continue working on the same command line (updatedb &).
The find command allows you to search for a file in a given directory. The first argument specifies the directory in which to start the search. The option -name must be followed by a search string to match a file name. The string may be specified using wild cards. Unlike locate, which uses a precompiled database, find scans the actual directory contents as exist on the disk.
The cat command displays the contents of a file, printing the entire contents on the screen without stopping.
Numbers the output on the left margin
This command can be used to browse the contents of the specified file. It allows you to scroll the text half a screen page up or down with PgUp and PgDn, respectively. Alternatively, scroll a full screen page down with Space. You can also jump to the beginning or the end of a document using Home and End. Pressing Q exits the program.
The grep command makes it possible to find a certain searchword in the file(s) as specified. If the search string is matched, the command displays the line in which the searchword has been found, along with the name of the corresponding file.
Ignores case
Only displays the names of the respective files, but not the text lines
Additionally displays the numbers of the lines in which it found a hit
Only lists the files in which searchword does not occur
The diff command compares the contents of any two files. The output produced by the program lists all lines where the files differ from each other.
This is frequently used by programmers who need only send their program alterations and not the entire source code.
Only reports whether the two given files differ
This command mounts any available data media (volumes) to integrate them into the overall Linux file system structure. After mounting a hard disk, a CD-ROM drive, or other drives or partitions, they can be accessed under a specific directory.
mount read-only
Specifies the file system. The most common are ext2 for Linux hard disks, msdos for MS-DOS media, vfat for the Windows file system, and iso9660 for CDs.
For hard disks not defined in the file /etc/fstab, the device type must also be specified. In this case, only root can mount. If the file system should also be mounted by other users, enter the option user in the appropriate line in the /etc/fstab file (separated by commas) and save this change. Further information is available in mount.
This command detaches (unmounts) a mounted drive from the file system. It must be run before taking out a removable data medium from its drive. Otherwise there is a risk of losing data. Normally, only root is allowed to run the commands mount and umount. To circumvent this, edit the /etc/fstab file to include user as one of the options for the corresponding drive.
The df (disk free) command, when used without any options, displays information about the total disk space, the disk space currently in use, and the free space on all the mounted drives. However, if a directory is given as an argument, the information is limited to the drive on which that directory is located.
shows the number of occupied blocks in gigabytes, megabytes, or kilobytes — in human readable format
Type of file system (ext2, nfs, etc.)
This command, when executed without any arguments, shows the total disk space as used by files and subdirectories in the current directory.
Displays the size of each individual file
Output in human-readable form
Displays only the calculated total size
The free displays information about RAM and swap space usage, showing the total and the used amount in both categories.
Output in bytes
Output in kilobytes
Output in megabytes
This simple program displays the current system time. If run as root, it can also be used to change the system time. Details about the program are available in the corresponding man page (date).
With top, get a quick overview of the currently running processes. Pressing H from within top shows a list that briefly explains the main options to customize the process table.
If run without any arguments, this command displays a table of all your ownprograms or processes — those started by yourself. Most options for this command do not need to be preceded by a dash.
Displays a detailed list of all processes, independent of the owner.
Unfortunately, sometimes a program cannot be terminated in the normal way. However, in most cases you should still be able to stop such a runaway program by executing the kill command, specifying the process ID (see top and ps) of the problem program as an argument.
It sends a TERM signal, which instructs the program to shut itself down. If this does not help, the following parameter can be useful.
Sends a KILL signal instead of a TERM signal, with which the process really is annihilated by the operating system. This brings the specific processes to an end in almost all cases.
This command is similar to kill, but is able to take a process name (instead of a process ID) as an argument, which causes all processes with that name to be killed.
The ping command is typically used to test whether a TCP/IP network link is up. It sends a small data packet to a destination host, requesting an immediate reply. If this works, ping displays a message to that effect, which indicates that network link is basically functioning.
number Determines the total number of packages to send and ends after they have been dispatched. By default, there is no limitation set.
flood ping: sends as many data packages as possible. A popular means, reserved to root, to test networks.
value Specifies the interval between two data packages in seconds. Default: one second
This command is related to the Domain Name System, which has the purpose of translating (resolving) domain names into IP addresses. With nslookup, send queries to the corresponding information servers (DNS servers).
Telnet is actually an Internet protocol that enables you to work on remote hosts across a network.
telnet is also the name of a Linux program that uses this protocol to enable operations on remote computers.
Do not use telnet over a network on which third parties can eavesdrop. Particularly on the Internet, use encrypted transfer methods, such as ssh, to avoid the risk of malicious misuse of a password (see the man page for ssh).
Users may change their own passwords at any time using this command. Furthermore, the administrator root can use the command to change the password of any user on the system.
The su command makes it possible to log in under a different user name from a running session. When using the command without specifying a user name, you will be prompted for the root password. Otherwise, supply the specified user's password and you may then work in that user's environment. However, if you do the latter as root, you will not have to supply any password: root can assume the identity of any user.
Always use this command to shut down your system in an orderly way to avoid loss of data.
Does the same as the halt command, with the difference that the system performs an immediate reboot.
This command cleans up the visible area of the console. It has no options.