An overview of the most important Linux commands

Like most modern operating systems, Linux also provides you with a shell, which you can use to control your system using command line commands. All of the settings that you set via the graphical user interface (GUI) can also be made via the shell. We show you the most important Linux commands and explain their function and application.
$1 Domain Names – Grab your favorite one
  • Simple registration
  • Premium TLDs at great prices
  • 24/7 personal consultant included
  • Free privacy protection for eligible domains

List of the 50 most important Linux commands

Command Description
sudo Run programs with the rights of another user
ls List directory contents
cd Navigation in the directory tree
touch Create new file
mkdir Create new directory
rm Delete file
rmdir Delete directory
mv Move file or directory
cp Copy file or directory
pwd Print current position in directory tree
zip Write files to zip archives
unzip Extract files from zip archives
ln Create symbolic link
cat Combine file contents
grep Search text files
diff Find differences between text files
cmp Align files at byte-level
tar Write and extract files to tar archives
echo Output string to the standard specification
clear Clear terminal
ssh Connect to another computer via a secure shell
wget Download file directly from the internet
ping Request server and measure latency
ftp, sftp Transfer files via (S)FTP
ip query and configure network interfaces
apt/pacman/yum Download and manage software packages
netstat Display network interface status
traceroute Track data packets
route Display and edit IP routing tables
dig Request DNS information
mount/unmount Integrate file systems (set up/mount)
dd Copy files, partitions or data carriers to the exact bit
chmod Manage access rights
chown Manage ownership rights
adduser Add/modify user account
passwd Create/edit passwords for user accounts
groupadd Create user groups
chattr Manage file attributes
lsattr Display file attributes
chgrp Manage group affiliations for files and directories
man Call up user manual
shutdown, reboot Shut down/reboot the system
top Dynamic process overview
lscpu Display processor information
lshw Output hardware information
kill Stop and terminate process via PID
killall Stop and terminate processes via name
nice Define process priorities
pgrep Identify PID via search term
ps Display list of all running processes

sudo command in Linux

The Linux sudo command(substitute user do) can set the program call to run with the rights of another user. As a rule, entering a password is required for this. The sudo command always asks for the password of the user account being called up.
If the command is entered without a username, then the superuser root is set as the target user.
sudo -u USERNAME PROGRAM CALL
bash

ls command in Linux

The Linux ls command line directive ls stands for list and is used to display the content of a directory (the names of all files and folders found in the given directory).
The syntax of the command reads:
ls [OPTIONS] DIRECTORY
bash
If ls is used without a directory entry, then the command lists the content of the current directory. With the help of additional options, you can define which information is shown and how it’s displayed.

cd command in Linux

The Linux cd command directive stands for change directory, and is used for navigation in the directory tree.
The syntax of the command reads:
cd [OPTION] DIRECTORY
bash
If no target directory is given, then cd automatically switches to the user’s home directory. If cd is used with a minus symbol after it (-), it changes back to the previous directory.

touch command in Linux

The Linux touch command line directive can be used to modify access and alteration time stamps for files. If touch is applied to a file that doesn’t exist yet, then it is automatically created, meaning that the command is also good for creating empty files. Use touch according to the following pattern:
touch [OPTIONS] FILE
bash
To set the time stamp for a file to the desired date, use the OPTION -t along with the time information in the forms [YY]MMDDhhmm[.ss].
Example:
touch -t 1703231037 file.txt
bash
Access and alteration time stamps are now set to March 23, 2017, 10:37. The modification can be restricted to access or time stamps with the options -a and -m. If the touch command is used without option -t, then it uses the current time stamp.

mkdir command in Linux

The Linux mkdir command stands for make directory, and allows Linux users to make new directories. Use the following syntax to create a new directory in the current directory:
mkdir [OPTION] DIRECTORY NAME
bash
If a directory is supposed to be created in a particular target directory, then specify the absolute or relative path to the directory.

rm command in Linux

The Linux rm command (remove) permanently deletes files or entire directories. The program call is based on the following syntax:
rm [OPTIONS] FILE/DIRECTORY
bash
If a directory is to be deleted along with all its subdirectories, then use rm plus the option -R (–recursive).

rmdir command in Linux

If you want to delete a particular directory, use the command line directive rmdir (remove directory) according to the following syntax:
rmdir [OPTION] DIRECTORY
bash
You can only delete empty directories with rmdir. To delete a directory along with all of its contained files and subfolders, use the command rm (remove) with the option –r.
In other articles you will find additional ways to delete a Linux file or delete a Linux directory.

mv command in Linux

The Linux mv command (move) copies a file or directory and deletes the original element. If it’s used within the same directory, then mv can be used to rename files.
The program call is based on the following syntax:
mv [OPTIONS] SOURCE TARGET
bash

cp command in Linux

The Linux cp command (copy) is used to copy files and directories. The basic syntax of the command reads:
cp [OPTIONS] SOURCE TARGET
bash
The SOURCE is the element that is intended to be copied. Either a file or a directory is then defined as the TARGET of the copying process. If you define an existing file as the target file, its contents are overwritten with the source file. You also have the option to create a new file with whatever name you choose as the target file.

pwd command in Linux

Use the Linux pwd command (short for print working directory) to output the name of the current working directory.
The syntax of the command reads:
pwd [OPTIONS]
bash

zip command in Linux

Use the zip command to compress several files into a zip archive. The syntax of the command is:
zip DESTINATION FILES
bash
The DESTINATION is the name or path of the resulting zip file. FILES refers to the file names or paths of the files to be compressed (separated by spaces).

unzip command in Linux

You can use unzip to extract files from zip archives. The syntax is:
unzip FILE.zip -d DESTINATION
bash
Here FILE refers to the zip archives where the files are to be extracted from. Optionally, you can use the -d TARGET option to specify a target directory where the resulting files are to be stored. Otherwise the files are stored in the current directory.

ln command in Linux

The Linux ln command (short for link) generates a shortcut to a file or a directory. This creates another directory entry for this file, which allows you to access the respective file via another file path. The call for ln has to always contain at least the path to the source file.
ln [OPTIONS] path/to/sourcefile
bash
In this case, a shortcut will be created in the current work directory under the same name. You can also enter a target path and then name the shortcut whatever you want:
ln [OPTIONS] path/to/sourcefile path/to/shortcut
bash

cat command in Linux

The Linux cat command (short for concatenate) was developed as a tool for the combination of file content and can be used as a pager for the display of file content in the terminal.
Use cat with the following syntax in the terminal to read a file and output it to stdout (the standard output):
cat OPTIONS FILE
bash
Multiple files can be separated by spaces:
cat OPTIONS FILE1 FILE2
bash

grep command in Linux

With the Linux grep command, you can search through text files. Any character strings or regular expressions can be used as a search pattern. Use grep according to the following syntax:
grep [OPTIONS] SEARCH PATTERN [FILE(S)]
bash
If grep encounters a string that corresponds to the search pattern, then the line number along with the file name is output to the terminal. In general, grep is used on all files in the current directory. The option -r enables a recursive search into the subdirectories.

diff command in Linux

The command line program diff serves to compare two files. You can also use diff to determine if two directories contain the same files.
Call up the program in the terminal using the following syntax:
diff [OPTIONS] FILE1 FILE2
bash

cmp command in Linux

cmp is part of the diff package and is used to compare file contents. As opposed to diff, the alignment is done at the byte level and so is particularly suitable for binary files. Use cmp according to the following syntax:
cmp [OPTIONS] FILE1 FILE2
bash
If cmp finds differences, the command line program outputs the byte and line number of the first deviation in the terminal.

tar command in Linux

The command tar allows you to write various files and directories sequentially into a tar file and use it as a backup for recovery if needed. Unlike the zip format common in Windows, all user rights of the archived file are retained even after unpacking. Use the following syntax:
tar [OPTIONS] FILES
bash
If you want to create a new archive, use tar with the options -c (create new archive) and -f (write archive to a given file or read from it). Find out more in our article on tar backups and how to create archives under Linux.

echo command in Linux

Use the Linux echo command to output strings line-by-line on the standard output (usually the terminal).
The general command syntax reads:
echo [OPTIONS] STRING
bash

clear command in Linux

Use the command line directive clear to clear the screen content.
clear
bash
You’ll receive a blank terminal with a prompt. Older entries remain in the scrollback buffer. Instead of using this command, you can also clear the terminal with the key combination [Ctrl] + [L].

ssh command in Linux

You can use ssh to connect your computer to an external computer via the SSH protocol, which means you are then in the shell of the other computer. The syntax is as follows:
ssh USERNAME@HOSTNAME
bash
Here, USERNAME and HOSTNAME denote the username under which you wish to log in and the address of the external computer.

wget command in Linux

You can use the Linux wget command to download files from the internet. Use the following syntax for this:
wget [OPTION] LINK
bash
Here LINK denotes the URL where the file can be found. You can optionally use the optional argument -c to continue a download that has been interrupted.

ping command in Linux

Use the Linux ping command to test the accessibility of other computers in the network. The command is based on the following syntax:
ping [OPTIONS] TARGET
bash
Together with the round-trip time (RTT) – the time span between sending the data package and receiving an answer – ping also writes the IP address of the target system in the terminal. You can use optional arguments to set the number of packets or seconds after which ping terminates itself.

ftp or sftp command in Linux

This gives you the possibility to exchange files between the local system and another computer in the network. Use FTP (File Transfer Protocol) according to the following syntax to establish a connection to the FTP server of the target computer:
ftp [OPTIONS] [HOST[PORT]]
bash
The addressing takes place via host name or IP address. Specifying a port number is optional. Only use FTP in networks that you trust, as this protocol is not secure. For security reasons, it is almost always advisable to use SFTP (SSH File Transfer Protocol). The command line program sftp functions like ftp to transfer data in the network, but here the transfer is encrypted. SFTP uses Secure Shell (SSH) as standard, i.e. also its authentication methods. We explain how to use SSH keys for your network connection in another article.

ip command in Linux

The command line program ip is part of the program collection iproute2, with which network interfaces are requested and configured via the terminal. The general syntax of the command reads:
ip [OPTIONS] OBJECT [COMMAND [ARGUMENT]]
bash
Which action is carried out by ip is defined with the help of objects, subcommands, and their arguments.
The program supports various objects, such as address (IP address), link (network interface), route (entry in the routing table), or tunnel, to which subcommands such as add, change, del, list, or show can be added.
For example, if you would like to access the IP address of a particular network interface (i.e. eth0), use the command ip in combination with the object address, the command show, and the argument dev eth0:
ip address show dev eth0
bash
We will show you how to display an IP address in Linux in more detail in another article.

apt, pacman and yum command in Linux

Every Linux distribution has a Packet Manager with which you can download and manage software packages. The syntax for app installation is as follows:
apt install [PACKET] # Debian-based distributions such as Ubuntu
pacman -S [PACKET] # Arch-based distributions
yum install [PACKET] # Red Hat-based distributions
bash
[PACKET] is the name of the package or program you want to install. In most cases, these commands must be executed via sudo in root mode. For other distributions that use other package managers, the commands may differ. Each manager also has commands to remove packages, update the package list and update all installed packages, among others. On Ubuntu, these commands are as follows.
apt remove [PACKET] # remove package
apt update # update package list
apt upgrade # upgrade packages
bash

netstat command in Linux

The command line program netstat is used to query the status of network interfaces. The general syntax of the command reads:
netstat [OPTIONS]
bash
Use netstat without option to output all open sockets in the terminal. You can also use the following options to see the routing table (-r), interface statistics (-i), masked connections (-M), or network link messages (-N). Find out more in our introduction to netstat.

traceroute command in Linux

To trace the transport route of an IP data packet between your system and a target computer, you can use the command traceroute. Use the following pattern.
traceroute [OPTIONS] HOSTNAME
bash
Via traceroute you can identify which router and internet nodes an IP package passes on its way to the target computer – for example, to investigate the cause of a delay.

route command in Linux

With the command line program route, the IP routing table of the core can be requested and edited. The command is based on the following syntax:
route [OPTIONS] [add|del] [-net|-host] TARGET
bash
Use the command without options to display the complete routing table of the core:
route
bash
If you want to set a route to a network, use the subcommand add.
route add -net 10.0.0.0
bash

dig command in Linux

dig is a lookup tool that can be used to request information from the DNS server and output it in the terminal. The command line program is generally used according to the following syntax to request the IP address and other DNS information on a given domain name:
dig [@SERVER] [DOMAIN] [TYPE]
bash
SERVER is the DNS server that should be searched for the desired information. If no server is given, dig identifies the standard DNS server from the file /etc/resolv.conf. DOMAIN stands for the domain name from which the DNS information should be identified. TYPE is used to specify the type of query, i.e. ANY (all entries), A (IPv4 record of a host), or AAAA (IPv6 record of a host). The standard request type is defined as A.

mount and unmount command in Linux

If a file system is to be integrated in the directory structure of the operating system via the directory structure, then the command line program mount is used under Linux. The general syntax of the command reads:
mount [OPTIONS] DEVICE MOUNTPOINT
bash
DEVICE = Path to the device file of the storage device that you want to mount as the partition.
MOUNTPOINT = The location in the directory structure of your operating system where you want to mount the partition. The mountpoint is usually specified as an absolute path.
Example:
mount /dev/sdd /media/usb
bash
The device sdd is mounted in the directory /media/usb.

dd command in Linux

The command line program dd enables a copying process in which data is read out bit for bit from an input file (if) and written into an output file (of). The program call is based on the following syntax:
dd if=Source of=Target [OPTIONS]
bash
As the source and target, you can specify individual files as well as entire partitions (i.e. /dev/sda1) or a complete storage device (i.e. /dev/sda).
dd if=/dev/sda5 of=/dev/sdb1
bash

chmod command in Linux

The command line program chmod (short for change mode) is used to assign rights in unix-like file systems (i.e. ext2, ext3, ext4, reiser, xfs). The general syntax of the command reads:
chmod [OPTIONS] MODE FILE
bash
or
chmod [OPTIONS] MODE DIRECTORY
bash
The MODE placeholder stands for the applicable rights mask. You can find out more about how to create a system like this and what to pay attention to in our guide on access rights with chmod. With the help of the -R option, rights can be assigned recursively to subfolders and files contained in a directory.

chown command in Linux

The Linux chown command stands for change owner and allows you to modify the owner permissions.
chown [OPTIONS] [USER][:[GROUP]] FILE
bash
or
chown [OPTIONS] [USER][:[GROUP]] DIRECTORY
bash
To set owner rights for a user or group, there are four possible combinations available. Owner and group are reset according to the input:
chown [OPTIONS] owner_name:group_name file.txt
bash
chown [OPTIONS] :group_name file.txt
# The owner is reset according to the input, the group remains unchanged:
chown [OPTIONS] owner_name file.txt
# The user is reset according to the input. The group is set to the default group for the logged-in user:
chown [OPTIONS] owner_name: file.txt
# The changes are recursively extended to subdirectories with the help of OPTION `-R`.
bash

adduser command in Linux

The simplest option for creating a user account is by using the command line program adduser. This is a Perl script based on the Linux useradd command and offers the same functions in a user-friendly way. The adduser command requires root privileges and is used according to the following syntax:
adduser [OPTIONS] USERNAME
bash
Use adduser without options to automatically create a user ID, home directory, and user group with the same name, in addition to the new user account.
adduser test
bash
This is followed by an interactive dialog in which you can define the password and other user information (real name, office number, telephone number, etc.).

passwd command in Linux

Use the Linux passwd command to change the password of a user or define, check, and change intervals. The command is based on the following syntax:
passwd [OPTIONS] USERNAME
bash
If you want to change the password of another user, then you need root permissions. Use the passwd command without a username to change your own password. If the password is supposed to be blocked, use the command passwd with the option -l (–lock). Other options give you the opportunity to define a duration for the expiration of passwords (-x) as well as warning (-w) and check intervals (-i).

groupadd command in Linux

The command line program groupadd is used to create user groups. Use groupadd with root permissions according to the following syntax:
sudo groupadd [OPTIONS] GROUPS
bash
Each newly-created group contains its own group ID (GID). Group IDs between 0 and 99 are reserved for system groups. If you want to define the GID for a new user group for yourself, use the command line directive groupadd with the option -g (GID). If you want to create a system group, use the option -r (root).

chattr command in Linux

The command line program chattr (short for change attribute) allows you to view files or directories with attributes. Use chattr according to the following syntax to set an attribute:
chattr [OPTIONS] +ATTRIBUTE FILE
bash
Replace the plus sign with a minus sign to remove attributes again. For example, set the attribute -i to prevent changes (deletions or modifications) to a file or directory. For other attributes and possible options, refer to the chattr program manual.

lsattr command in Linux

If you would like to display which attributes are set for a file or directory, use the command line directive lsattr (short for list attributes) according to the following syntax:
lsattr [OPTIONS] FILE/DIRECTORY
bash

chgrp command in Linux

The command chgrp stands for change group and is used for the management of group affiliations for files and directories. To be able to use chgrp on a chosen file or directory, you have to have owner or root permissions. These are the only groups to which you can belong. chgrp is used according to the following syntax:
chgrp [OPTIONS] GROUP FILE
bash
or
chgrp [OPTIONS] GROUP DIRECTORY
bash
The option -R refers to subfolders and files contained in a directory.

man command in Linux

The man command opens the manual pages (man-pages) of your Linux distribution directly in the terminal. Use the following scheme to call the manual pages:
man [OPTION] TOPIC
bash
The Linux man-pages are divided into 10 topic areas: User commands, system calls, functions of the programming language C, file formats, configuration files, games, miscellaneous, system administration commands, core functions, new commands.

shutdown command in Linux

The Linux shutdown command can be used by the root user to shut down the system. The command is based on the following syntax:
shutdown [OPTIONS] [TIME] [MESSAGE]
bash
If you want to induce a shutdown, you have the option to define a time that the system should be turned off. For this, use either a concrete time input (hh:mm) or a countdown (+m). Other users on the system will get a shutdown message. This can be accompanied by a personal message, if needed. If the command shutdown is used with the option -r, the shutdown of the system is followed by a reboot.

top command in Linux

The command top calls a dynamic overview of all running processes. The call is based on the following pattern:
top [OPTIONS]
bash
The output of the process information can be adjusted using various options. The top process overview (among others) supports the following hotkeys to sort through the outputs:
  • [P] = Sorts the output according to CPU load
  • [M] = Sorts the output according to storage requirements
  • [N] = Sorts the output numerically by PID
  • [A] = Sorts the output by age
  • [T] = Sorts the output by time
  • [U USERNAME or UID] = Filters the output by respective user
Use the hotkey [H] to display a help page, or [Q] to close the process overview.

lscpu command in Linux

Use lscpu (short for list cpu) according to the following pattern to output information about the CPU architecture in the terminal.
lscpu [OPTIONS]
bash
For possible options, refer to your operating system’s manual.

lshw command in Linux

The command lshw stands for list hardware and outputs information about the hardware components in the terminal. Use lshw according to the following syntax:
lshw [OPTIONS]
bash
The command supports various options for customizing the output format (-html, -xml, -short, -businfo) as well as the range of information (i.e. –sanitize to hide sensitive information).

kill command in Linux

kill is a command line program with which processes can be stopped and finished. The command is passed on according to the following pattern with a desired signal and the ID of the chosen process.
kill [OPTIONS] [-SIGNAL] PID
bash
Common signals are:
  1. TERM: Causes a process to end itself (standard)
  2. KILL: Forces the end of a process (through the system)
  3. STOP: Stops a process
  4. CONT: Allows a stopped process to continue

killall command in Linux

Use the Linux killall command in combination with a particular search term to only end the processes whose names coincide (the first 15 characters are used to match).
killall [OPTIONS] [-SIGNAL] [PROCESS NAME]
bash
The option -e (–exact) allows you to extend the match to all characters of the process name.

nice command in Linux

The command line directive nice indicates a process value between -20 and +19 at the start of a process in integer steps, after which the available computing power of the system is distributed. The range of -20 to +19 corresponds to the Linux priority levels 100 to 139. A process with a nice value of -20 has a higher priority than a process with a nice value of 19. The solo syntax reads:
nice [OPTION] [COMMAND]
bash
Without additional specification, every process starts with a nice value of 0- Use the option -n to define the process priority. It should be noted that negative priorities can only be assigned with root permissions.

pgrep command in Linux

The command line program pgrep matches the list of running processes with a search term and outputs the respective PIDs if there are matches. The general syntax reads:
pgrep [OPTIONS] Search term
bash
By default, pgrep outputs the PIDs of all processes that contain the search term. If the search is to be limited to only exact matches, then use the command along with the option -x. If you would like to obtain the PID in addition to the process name, use pgrep with the option -l. Similarly to grep, pgrep supports search terms based on regular expressions.

ps command in Linux

The Linux ps command outputs a list of all running processes in the terminal.
ps [OPTIONS]
bash
If you need a detailed output, use ps with the options -f (detailed) or -F (very detailed). For additional options, refer to your operating system’s manual.

Additional Linux commands at a glance

Basic commands

In the basic commands category, you’ll find the Linux basic commands that are used to control the terminal. Learn how to clear the terminal’s visibility, retrieve previous terminal entries from the history, or exit the terminal session.
1. exit
The command line directive exit ends the current session and closes the terminal.
exit
bash
Instead of this, you can use the key combination [Ctrl] + [D].
2. help
Use the help command to see a list of all integrated shell commands (built-in commands). Call up help in combination with a shell command to retrieve a short description of the demand in question.
help COMMAND
bash
3. history
In Bash, the last 500 commands entered in the command line are saved in the history. This function serves as entry assistance, and allows you to look through the list of previous commands using the arrow keys and execute them again.
The history can be searched using keywords with the key combination [Ctrl] + [R]. You also have the option to view the complete list, numbered in the terminal. Use the command history without options and arguments.
history
bash
If you want to filter the results, combine history via Linux Pipe with the command line program grep (see search options) and a search term.
history | grep SEARCH TERM
bash

Help pages

Are you stuck on what to do? No worries. Under Linux, there are various help and documentation pages available directly via the terminal, such as the Unix man-pages and GNU info pages. These contain a detailed description of all command line programs, system calls, configuration files, file formats, and core functions. With the Linux whatis command and apropos, you can find command line programs in the help pages category, which allow you to search the manual pages of your operating system for keywords.
1. apropos
Use apropos to search the page titles and descriptions of your operating system’s manual by keywords. Refer to the following scheme:
apropos [OPTIONS] SEARCH TERM
bash
The command supports different options. Use the -e option to limit the search to exact matches, or use wildcards (-w '*SEARCH TERM') and regular expressions (-r).
2. info
Via the info command, you can retrieve the GNU info pages for a specific topic. In most cases, these pages correspond to the manual pages that can be accessed via man, but as opposed to these, they have links that make the navigators in the manual simpler to read. Use the following syntax:
info [OPTION] TOPIC
bash
A call without an option or topic leads you to the main menu of the GNU info page.
3. pinfo
With pinfo, you have a variant of the command line program info, which is based on the command line browser Lynx and issues information pages with highlighted links. Use pinfo the same way as the info command:
pinfo [OPTIONS] TOPIC
bash
4. whatis
The command line program whatis serves as a keyword search in the manual pages. Call this program with a popular keyword to search your operating system’s manual for exact matches. If there is a match, whatis gives a brief description in the terminal.
whatis [OPTIONS] SEARCH TERM
bash
whatis (-w '\*SEARCH TERM') also supports placeholders and regular expressions (-r).

Directory operations

You’ll use Linux commands for directory operations to create, delete, and manage directories on your system through the terminal, as well as navigate the directory tree. The most important command line directives in this category are cd, ls, mkdir, and rmdir.
1. chroot
The chroot command (short for change root) is used to execute a command in a different root directory. For example, chroot is used to isolate critical programs from the rest of the file system. Calling the program requires root privileges, and is based on the following formula:
chroot DIRECTORY COMMAND
bash
2. mkdirhier
With mkdirhier you can create entire directory hierarchies with a single command line directive:
mkdirhier [OPTION] /home/user/directory1/directory2/directory3
bash
If directory1 and directory2 already exist, mkdirhier only creates directory3. Otherwise, all three directories are created.
3. tree
While ls only lists the content of a directory, the command line directive tree can be used to output the entire directory hierarchy recursively as a tree structure. The command uses the following syntax:
tree [OPTIONS] [DIRECTORY]
bash

File operations

The Linux commands in this chart allow you to carry out various file operations from the terminal. Use the Linux basic commands like cp, mv, and rm to copy, move, rename, or delete files on your system.
1. basename
A file path is passed to the command line directive basename, which simply returns the file name without a default path. The syntax of the command reads:
basename [OPTIONS] path/to/files [SUFFIX]
bash
The command can be expanded to multiple files using options.
2. comm
Use the command line program comm to compare sorted files (i.e. via sort) line by line. The program call is based on the following syntax:
comm [OPTIONS] FILE1 FILE2
bash
The program supports three options:
  • -1: suppress unique lines from FILE1
  • -2: suppress unique lines from FILE2
  • -3: suppress all lines contained in both files
3. cut
The cut command allows you to extract the contents of a file from the text line of a file (i.e. log or CSV files). The syntax of the command reads:
cut [OPTIONS] FILE
bash
The exact position of an extracted section is defined via the options -b (byte position), -c (character position), -d (delimiter), and -f (field).
4. dirname
dirname is the counterpart to basename. The command line directive allows you to extract the path portion from a file path and output it in the terminal without file names. The syntax of the command reads:
dirname [OPTIONS] path/to/file
bash
5. file
With the command line directive file you can output information about the file type of a file. The call is based on the following syntax:
file [OPTIONS] FILE
bash
6. lsof
The Linux lsof command stands for list open files, a tool that gives you information about open files in the terminal, sorted by PID (process ID). Call the program to the terminal using the following syntax:
lsof [OPTIONS]
bash
Since unix-like systems such as Linux generally follow the policy that “Everything is a file,” the list outputted by the lsof command is accordingly long. As a rule, the options are used to limit this output.
7. md5sum
The command line directive md5sum helps you calculate and check MD5 checksums for files.
8. paste
Similar to cat, the command line program paste also enables the output of file contents to the standard output. But while cat merely combines content, paste joins column by column. The basic syntax of the command reads:
paste [OPTIONS] FILE1 FILE2 …
bash
You can customize which separator is used by paste with the option -d. Tabs are used as the default separator. A second mode can be activated using the -s option (serial). With this, all lines of the first input file are transferred to the first line of the output. The data for all other input files follows in separate output lines, so each line of the output contains the contents of only one input file.
9. rename
The command line program rename enables the renaming of files and folders with the help of regular expressions (regex). As opposed to mv, the rename function is suitable for file operations where the names of several files are supposed to be either partially or completely adapted. Use rename according to the following syntax:
rename [OPTIONS] 'REGULAR_EXPRESSION' FILE
bash
Regular expressions correspond to the following syntax for replacements:
s/SEARCHPATTERN/REPLACEMENT/MODIFIER
bash
10. shred
shred is a command line program that enables safe deletion of files. Chosen elements are overwritten in the course of the deletion process and so can’t be restored by forensic means. The overall syntax of the command reads:
shred [OPTIONS] FILE
bash
11. sort
Use the command line directive sort to sort file lists and program output numerically, alphabetically, and by row. The overall syntax of the command reads:
sort [OPTIONS] FILE
bash
The sorting method can be customized using options. For example, numerical (-n), random (-R), or in reverse order (-r).
12. split
The command line directive split is used to divide files. The underlying syntax reads:
split [OPTIONS] [INPUT [PREFIX]]
bash
The placeholder INPUT corresponds to the file that is to be split. The PREFIX acts for the names of the participating files. Their name is based on the following pattern:
PREFIXaa, PREFIXab, PREFIXac …
bash
If no prefix is defined, split uses the default prefix x. The -b (bytes) option can be used to specify the size of the partial files. This can be specified either in bytes (b), kilobytes (k) or megabytes (m).
Example:
split -b 95m archive.tgz split-archive.tgz.
bash
13. stat
The command line directive stat (status) outputs access and alteration time stamps for selected files and directories. The general syntax of the command reads:
stat [OPTIONS] FILE
bash
The output format can be customized with the use of options.
14. uniq
The command line directive uniq is usually used in combination with sort to clean sorted files from duplicate lines. In the following example, the sort command is linked by a pipe (|) to the uniq command to first sort a file and then output it without duplicate lines.
sort file.txt | uniq
bash

Search options

Linux offers various command line directives for searching through the system directly from the terminal.
1. find
Using find helps you to search through a Linux file. This is based on the following syntax:
find [OPTIONS] [DIRECTORY] [SEARCHCONDITION] [ACTIONS]
bash
The specified directory is the starting directory of the search. The command then searches the starting directory and its subdirectories. If no directory is entered, then find starts the search from the current working directory.
Options allow you to define search criteria and actions. The default action is preset at -print: The output of the complete file names of all search results to the standard output (usually the terminal). Further options make it possible to filter by file name, file size, time of access, etc. These are listed on the corresponding man-page.
2. locate
The command line program locate also allows you to search for files through the terminal. But as opposed to find, instead of searching through the file directory, it searches a specially created and regularly updated database. As a result, locate provides results must quicker than find. To search the database for a particular file, locate is used according to the following syntax:
locate SEARCHPATTERN
bash
The search pattern can contain meta-characters as placeholders (*). Put these in quotation marks to prevent interpretation by the shell.
3. tre-agrep
tre-agrep also is used to search for strings in text files based on search patterns. But unlike grep, it’s not only exact matches that are output, but vague results are also allowed, such as those with transposed letters or missing characters. The program is based on the TRE library and makes it available in the command line. The syntax of tre-agrep matches that of the grep command:
tre-agrep [OPTIONS] SEARCHPATTERN FILE(S)
bash
Using options, you can define a maximum error allowance. In the following example, a maximum of one deviation is tolerated.
tre-agrep -1 'Linux' test .txt
bash
4. updatedb
A locate search only functions properly if the /var/lib/locatedb file is continuously kept up to date. The updatedb command allows you to manually update the database. Note that you need root permissions to do this:
updatedb
bash
5. whereis
With the whereis command, you can locate the binary code, source code, or manual files of the selected program. The general syntax of the command reads:
whereis [OPTIONS] PROGRAM
bash
Options can be used to limit the search to specific file types or directories.
6. which
If you would like to identify the binary files of a program, use the command which with the following syntax to output the path in the terminal.
which [OPTIONS] PROGRAM
bash
In the default mode, which outputs the first file it finds. Use the option -a to show all files that fulfill the search criteria.

User information

Use the command line programs for the following categories to access detailed information on the registered users in the system as well as their groups and processes.
1. finger
The command line program finger serves to access user information. Use the command in combination with the desired username:
finger [options] [USERNAME]
bash
Use finger without a username to obtain information about your own account.
2. groups
The command groups lists the group affiliations of a selected user account. Use groups without a username to list all groups to which your user account belongs.
Use the command line directive according to this pattern:
groups [OPTIONS] [USERNAME]
bash
3. id
The command line directive id outputs user and group identifiers of the selected user accounts. If you want to identify your own IDs, use the command without a username.
id [OPTIONS] [USERNAME]
bash
The range of the output can be limited using options.
4. last
Use the command last according to the following pattern to view a list of recently logged-in users, including login and logout times.
last [OPTIONS] [USERNAME]
bash
The corresponding information is obtained from the wtmp file under /var/log/wtmp. If you only want to request information about a particular account, then enter the command line directive with the desired username.
5. w
The command w outputs a list of all registered users including all processes that they’ve executed. Use w in combination with a username to limit the command to just this user account:
w [OPTIONS] [USERNAME]
bash
Range and format of the output can be customized using options.
6. who
The command who outputs detailed information about users registered on the system. The general syntax of the command reads:
who [OPTION] [SOURCEFILE]
bash
By default, who refers to data about currently registers users from the /var/run/utmp file. You have the option to specify one of the following files as the source of the information.
7. whoami
Use the command whoami to obtain your own username.
whoami [OPTIONS]
bash

User account management

Linux provides you with a series of programs with which you can create, delete, and manage user accounts and groups directly from the terminal. An overview of the important Linux commands for user account management is put together for you here. You’ll also find Linux terminal commands in this category that enable you to access code with other user rights, including the super-user root.
1. chfn
The command line directive chfn (short for change finger) allows you to customize additional information on a user account, such as the real name, office number, and private or work telephone numbers. The general syntax reads:
chfn [OPTION "NEW VALUE"] [USERNAME]
bash
Which user information will receive a new value is defined with the help of the option -f (real name), -r (office number), -w (work phone), and -h (private phone).
2. chsh
The command line directive chsh (short for change shell) changes the login shell of a chosen user. Use the following pattern as a guide when entering the data:
chsh [OPTIONS] USERNAME
bash
You can use the -s option to change the login shell of a user account.
3. deluser
The command line program deluser deletes all entries for a selected user account from the system account files. Calling deluser requires root permissions and uses the following syntax:
deluser [OPTIONS] USERNAME
bash
If you would also like to delete all files from the home directory of the user, then use the command with the options --remove-home. If you want to delete all user files from the system, use the options --remove-all-files.
4. delgroup
The command line directive delgroup (short for delete group) deletes an existing user group. To execute the command, root permissions are required. The general syntax of delgroup is:
delgroup [OPTIONS] GROUP
bash
5. groupmod
Names and group IDs (GID) of existing user groups can be customized via groupmod. The command line directive is used with root permissions according to the following syntax:
groupmod OPTIONS GROUP
bash
Use groupmod with the option -g to customize the GID. Call the command with the option -n to overwrite the group name.
6. newgrp
The command newgrp (short for new group) allows registered users to change their current group ID without having to log out and back in. The general syntax of the command reads:
newgrp [-] [GROUP]
bash
If the newgrp command is used with the optional parameter [-], then the group change causes a restart of the user environment – as if the user had logged in again. Those who use newgrp without group specification change to the default group specified under /etc/passwd.
7. su
The command su also allows for a temporary user change to run a program call with the rights of a target user. As opposed to sudo, the command is not directly executed. Instead, a change of identity occurs. Instead of asking for the password of the calling user, the target user password is requested. The general syntax of the command reads:
su [OPTIONS] [USERNAME]
bash
A call without a USERNAME selects root as the target user.
8. usermod
The command line directive usermod gives you the option to edit previously created user accounts. Use usermod with root permissions according to the following syntax:
usermod [OPTIONS] USERNAME
bash
Which modifications are intended can be defined with the help of options. For example, you can change the username with the -l NEW_NAME option. Further options can be found on the corresponding man-page.

System commands

In the system commands category, you’ll find the basic Linux commands for system control. Use the following commands to restart and shut down the system from the terminal – and control them with a timer, if desired.
1. logger
Use logger according to the following pattern:
logger "YOUR MESSAGE"
bash
Find the system log under /var/log/syslog.
2. reboot
The command line directive reboot causes a restart of the system. To trigger a restart, the command has to be executed with root permissions.
reboot [OPTIONS]
bash
3. rtcwake
The command line directive rtcwake allows you to start and shut down the system according to a timer. The command is based on the following syntax:
rtcwake [OPTIONS] [MODE] [Time]
bash
Choose a particular mode (-m MODE) for the system to move to at a particular time in seconds (-s TIME IN SECONDS). You also have the option to wake up your system at a precisely defined time (-t UNIXTIME).

System information

In the system information category, we’ve collected command line programs with which you can obtain information and status reports, giving you a comprehensive overview of the state of your system.
1. date
The command date outputs the system time including the date.
date [OPTIONS] [OUTPUTFORMAT]
bash
If you want to work with a particular time in the context of a program call (see rtcwake), define this with the help of the option -d 'DATE'. In addition, various options are supported that can transfer date and time information to a desired format.
2. df
Use the command df (disk free) according to the following pattern.
df [OPTIONS] [FILE]
bash
If the command is used in combination with a particular file, the system only specifies the free space on the partition where the file is located. Otherwise, the free hard disk space of mounted partitions is displayed. The option -l (local) restricts df to the local file system. It also supports options that let you customize the output format.
3. dmesg
The program dmesg (short for display message) outputs core circular buffer messages in the terminal and allows you to localize hardware and driver failures. Use dmesg according to the following pattern:
dmesg [OPTIONS]
bash
The dmesg output contains all messages of the boot routine, and is accordingly long. The command line program is often used in combination with a pager, like more, less, or tail.
4. free
The command free outputs the memory usage. The general syntax reads:
free [OPTIONS]
bash
As output, you’ll get two specifications: Mem (Memory) and Swap. Free also supports the option -h for outputting the memory usage in a human-readable format.
5. hostname
Use the command hostname according to the following pattern to display the DNS names of the system.
hostname [OPTIONS]
bash
6. uname
The command line directive uname stands for unix name and is used to access system information from the core. The command supports various options with which the output can be filtered according to the desired information. These can be found in the corresponding man entry.
uname [OPTIONS]
bash
7. uptime
If you want to determine how long the system has been running since the last reboot, use the command line directive uptime according to the following pattern:
uptime
bash
8. vmstat
With the help of the monitoring tool vmstat, you can access information about virtual memory, reading and writing procedures on the disc, and CPU activity. Call vmstat according to the following syntax to output the average values since the last system start.
vmstat [OPTIONS]
bash
vmstat also offers a continuous monitoring mode that accesses system values as often as requested in a desired time interval in seconds.
vmstat [Options] [INTERVAL [REPETITIONS]]
bash

Hardware information

Linux commands in this category deliver detailed information about the hardware components that form the foundation of your system.
1. lspci
Use lspci (short for list pci) according to the following pattern to output detailed information about PCI devices.
lspci [OPTIONS]
bash
For possible options, refer to your operating system’s manual.
2. lsusb
Use lsusb (short for list usb) to output detailed information about USB devices in the terminal.
lsusb [OPTIONS]
bash
For possible options, refer to your operating system’s manual.

Process management

On Linux, the instance of a running program is called a process. The following terminal commands are part of the standard repertoire of the process management, and allow you to supervise all processes on your system easily from the terminal and control as necessary.
1. chrt
The command line program chrt deals with continuous process controls and makes it possible to identify and customize the real-time attributes (scheduling regulation and priority) of running processes, or execute commands and their arguments with specified real-time attributes. The general syntax of the command reads:
chrt [OPTIONS] [PRIOTITY] PID/COMMAND [ARGUMENT]
bash
Use chrt without entering a priority and with the option -p to identify the real-time attributes of chosen processes.
chrt also offers the possibility to set or define the scheduling regulation of running or newly started processes with the help of options. Further information on this can be found in the corresponding man entry.
2. ionice
The command line directive ionice is used to influence the priority of a process that uses the I/O interface of the core. The general syntax of the command reads:
ionice [OPTIONS] COMMAND
bash
To be able to execute ionice, you need root permissions. The command distinguishes between three scheduling classes that are passed on using the -c class option. Possible values are 1, 2, and 3.
  • 1 = Real time: The I/O action is executed immediately.
  • 2 = Best effort: The I/O action is executed as quickly as possible.
  • 3 = Idle: The I/O action is only executed when no other process is taking I/O time.
3. nohup
Normally, all of a user’s dependent processes are automatically ended as soon as the terminal session is closed (i.e. via exit). The Linux nohup command (short for no hangup) deletes a command from the current session and allows you to keep it running even when you log out of the system.
nohup COMMAND
bash
4. pidof
The command line program pidof outputs the process identification numbers (PIDs) of all of a program’s processes. Identify PIDs via pidof according to the following pattern:
pidof [OPTIONS] PROGRAM
bash
If you would like to output only the first process ID, use pidof in combination with the option -s (short for single shot).
5. pidkill
Like kill, the command pkill also sends a signal to a chosen process. The addressing isn’t done by PID, though. Instead, a search term is given that matches the name of the running process. This can also be formulated as a regular expression. pkill forwards the standard signal TERM, as long as no other signals are defined. The general syntax of the command reads:
pkill [OPTIONS] [-SIGNAL] [SEARCHTERM]
bash
Additional options can be used to limit the command to the processes of a particular user (-U UID), the sub-processes of a particular parent process (-P PID), or the newest (-n) or oldest (-o) processes.
6. pstree
Use pstree to display all running processes in a tree structure. The general syntax of the command reads:
pstree [OPTIONS]
bash
The format and range of the output can be customized using various options.
7. renice
The command line directive renice allows you to customize the priority of a running process. The general syntax reads:
renice PRIORITY [OPTIONS]
bash
8. sleep
The Linux sleep command allows you to disrupt the current terminal session for a given time. The general syntax of the command reads:
sleep NUMBER[SUFFIX]
bash
If you use sleep without a suffix, the given number will be interpreted as time in seconds (s). You also have the option to disrupt the terminal session for minutes (m), hours (h), or days (d).
9. taskset
The command line directive taskset is used for advanced process control, which is used in multiprocessor systems to assign processes or commands to specific processors. The command requires root permissions and uses one of the following patterns:
taskset [OPTIONS] MASK COMMAND
taskset [OPTIONS] -p PID
bash
Assigning a process or command to a processor happens using a hexadecimal bitmask. Since assigning via bitmask like this isn’t very intuitive, taskset is generally used with the option -c (–cpu-list) to enable a numerical assignment of processors (i.e. 0, 5 7, 9-11).

Pager

Do you want to use your overview to keep track of multi-page file content? With a command line program from the pager category, you can select which sections are displayed in the terminal and scroll through the file in interactive mode if necessary.
1. head
The Linux head command is used to output the first part of a file. The general syntax of the command reads:
head [OPTIONS] File
bash
Use the option -n NUMBER_LINES to define how many lines are to be output, starting at the beginning.
2. less
The command line program less enables the display of the content of a text file in the terminal. The general syntax reads:
less [OPTIONS] FILE
bash
The output is automatically in interactive mode. This allows you to scroll through the selected document or search by keyword. The [Q] key ends the interactive reading mode. Other control keys and available options can be found in the program’s manual.
3. tail
While head displays the first 10 lines of a chosen file by default, the Linux tail command outputs the last 10. Both pagers are used according to the same pattern (refer to head).

Editors

Under Linux, you don’t need a graphical text editing program to customize configuration files, edit code snippets, or draft short notes. Simple text editors can be easily called up in the terminal without time delays. Here we present three programs that you should know.
1. emacs
Emacs is a cross-platform text editor, which can be expanded as desired by a programming interface. By default, Emacs starts with a graphical user interface, but can also be opened in the terminal using the option --no-window-system.
emacs --no-window-system
bash
Emacs has an available integrated tutorial that you can call up with the key combination [CTRL] + [H], [T].
2. nano
Nano is a terminal-based text editor. Nano offers a smaller range of functions than comparable editors (i.e. Vim), but is characterized by a particularly user-friendly operation. The general syntax of the program call reads:
nano [OPTIONS] FILE
bash
The program opens the given file in an editing window in the terminal. If you call Nano without file names, a new text file can be created that’s stored in the currently selected directory.
3. vim
Vim (short for Vi Improved) is a further development of the text editor Vi that stands out due to numerous extensions such as syntax highlighting, a comprehensive help system, native scripting, automatic code completion, and visual text selection.
The open-source program offers various modes of operation for editing pure text files, and can be used either in the terminal or as a stand-alone application with a graphical user interface (GVim). A central application area of the program is the editing of program code.
If you start Vim in the console, the operation is done via keyboard. Generally, the program is called together with a text file according to the following pattern:
vim [OPTIONS] FILE
bash
Vim offers the program vimtutor as a comprehensive introduction, which is also started from the command line. Our basics article on the Linux Editor Vim also offers additional information on the installation and various operating modes of the program.

Network management

Network management is also managed easily from the terminal in Linux. Whether you want to test the connection, request DNS information, configure the interface, or transfer files to another computer in the network, with the following programs a single command is sufficient to put your project into motion.
1. arp
The command line program arp allows you to access and manipulate your operating system’s ARP cache. Use arp without a modifier to output the content of the ARP table in the terminal.
arp [OPTION]
bash
Alternatively, you can limit the output with options or create or delete entries:
  • -a HOSTNAME = Limit output to entries for specific host names (alternative to an IP address)
  • -s HOSTNAME MAC_ADDRESS = Create ARP entry with specified host name and MAC address
  • -d HOSTNAME = Delete APR entry
2. iw
The command line program iw is used for the configuration of WLAN interfaces and is established as a current alternative to iwconfig. The call is based on similar syntax to that of the ip command:
iw [OPTIONS] OBJECT [COMMAND]
bash
Possible objects are:
  • dev NAME_OF_INTERFACE = Network interface
  • phy NAME_OF_DEVICE = WLAN device (by name)
  • phy#INDEX_OF_DEVICE = WLAN device (by index)
  • reg = Regulatory agent for the configuration of regional and country settings
An overview of the possible commands and options can be found in the corresponding man entry.
3. nslookup
Like dig, nslookup is also a name resolution service. The command line program is available in two modes: interactive and non-interactive. If you want to use nslookup in non-interactive mode, call the program in combination with a host name or an IP address.
nslookup [OPTIONS] [HOST/IP]
bash
To start interactive mode, enter the command nslookup in the terminal without any additional information and then enter host names or IP addresses to display the associated IP addresses or host names.
Since the program is officially outdated, users are encouraged to use dig instead.
4. rsync
The command line program rsync enables you to synchronize files locally or over a network. For this purpose, the size and modification time of the concerned files are compared. The syntax of the call reads:
rsync [OPTIONS] SOURCE(S) TARGET
bash
The command rsync is generally performed with the option -a, which ensures that all subdirectories and symbolic links are copied and all user rights take effect.
5. scp
With the Linux scp command (short for secure copy), another program for secure data transfer in the network is available directly via the terminal. scp copies data from one computer to another and uses the network protocol SSH. The client program functions in the same way as the file option cp, but is used system-wide according to the following syntax:
scp [OPTIONS] FILE [[user@]remote_host:]PATH
bash
When specifying the path of the remote computer, the username and the respective hostname are placed in front. Local files are explicitly addressed using relative or absolute paths.
Example:
scp/home/max/images/image.jpg max@example.com:/home/max/archive
bash
Additional options allow you to make adjustments to the transfer mode and the encryption settings.
6. tty
The command line directive tty outputs the file names of the terminal that are defined as the standard input. The general syntax of the command reads:
tty [OPTIONS]
bash

Archive and compress

Linux offers various technologies with which files can be packed and compressed in archives. It should be noted that not every archive contains a compression. So tar – a program for the archiving of files – is usually combined with a compression program like gzip, bzip2, or xz.
1. gzip
gzip is a program with which you can easily compress or decompress files via the command line. The general syntax of the command reads:
gzip [OPTIONS] FILE(S)
bash
Note that by default, gzip deletes the original file as part of the packing process. Prevent this by using the option -k. The program can be used for multiple files at the same time, if necessary. Each output file is converted into a separate gz file. If you want to write several files in a single compressed archive, use gzip in combination with the archiving program tar.
If you want to decompress a gz file, use the gzip command with the -d option.
2. bzip2
A popular alternative to gzip is the command line program bzip2. This uses the same syntax as gzip, but is based on a three-stage compression process which allows for a significantly higher compression ratio. Files that are compressed with bzip2 use the file ending .bz2. Use bzip according to the following pattern to compress files:
bzip2 [OPTIONS] FILE(S)
bash
bzip2 can also be applied to tar archives. The decompression is analog with gzip and runs with the help of option -d.
3. xz
The command line program xz converts files in the same-named data compression format xz. The program call uses the same pattern as gzip and bzip2.
xz [OPTIONS] FILE(S)
bash
Files that are compressed with xz use the file ending .xz. The decompression functions as with gzip and bzip with the option -d. The command unxz can also be used.
Like gz and bz2 files, xz files are also not archive files. If you would like to write multiple files into the same compressed xz file, you will also have to use the archiving tool tar with this compression program.
4. cpio
The archiving program cpio (short for copy in, copy out) allows you to write data in an archive file (.cpio) and extract data from it.

Partition management

If you want to access a file system on another partition in Linux, you first have to integrate it into the directory structure of your operating system. This is called “mounting” a partition. If necessary, this can happen via the graphical user interface. Command line programs like lsblk, blkid, and mount also offer the ability to request information about connected block storage devices and to mount or unmount them when necessary.
1. lsblk
Use the command lsblk (short for list block devices) to represent all connected block storage devices and partitions as a tree structure. These don’t necessarily have to be involved. The call is based on the following syntax:
lsblk [OPTIONS]
bash
If necessary, the output and a list of desired attributes can be individually modified using the -o (–output) option to retrieve additional information, like the identification number (UUID), file system (FSTYPE), or the state (STATE).
In the standard settings, empty storage devices are bypassed. If you also want to include these in the overview, use lsblk in combination with the option -a (–all). If you only want to request information on a particular device, use lsblk according to the following pattern:
lsblk [OPTIONS] DEVICE
bash
2. blkid
Similar to lsblk, blkid also outputs information on connected block storage devices. Use blkid according to the following pattern to obtain the identification number (UUID) and file system type (TYPE) of all connected block storage devices.
blkid [OPTIONS]
bash
For tabular output, use the -o option in combination with the value list. You can also limit blkid to a chosen device:
blkid [OPTIONS] DEVICE
bash

Miscellaneous

The following list contains additional Linux basic commands that don’t belong to any of the previous categories.
1. alias
Interaction with the shell is usually via commands that can be used to call up command line programs of the same name. You use a program call for every action you want to perform via the terminal. The Linux alias command allows you to define short names for program calls. Use alias according to the following pattern:
alias NICKNAME= 'COMMAND'
bash
Replace the placeholder COMMAND with any command line directive, including options. This will link the inserted string for the placeholder NICKNAME.
2. at
Call the command line program at according to the following pattern to run a time-controlled command.
at TIME
bash
Then enter the command and close the interactive mode with [CTRL] + [D].
3. cal
Use cal according to the following pattern to output a calendar in the terminal.
cal [OPTIONS] [[MONTH] Year]
bash
4. pr
Use the command line program pr to prepare text files for printing. The general syntax of the command reads:
pr [OPTIONS] File
bash
In the standard settings, pr generates a page header that contains the file name, current date, and page number.
5. script
The command line program script allows you to record a terminal session in the file typescript. If there’s already a recording of a previous session in typescript, then it’s overwritten. The recording automatically starts with the program call:
script
bash
Use the key combination [CTRL] + [D] to end the recording. If you would like to save the recording in another file instead of in typescript, call script in combination with a file name or path.
6. seq
Use the command seq to output a numerical series in the standard output. Define a start value, an end value, and an increment (optional).
seq [OPTIONS] STARTVALUE INCREMENT ENDVALUE
bash
7. tasksel
The command line program tasksel serves as installation help for standard applications (mail server, DNS server, OpenSSH server, LAMP server, etc.). Use the tool to automatically install all packages and programs required for a task in the correct order. Call tasksel with the option --list-tasks to output a list of all available standard applications.
tasksel --list-tasks
bash
If you want to access more information about a standard application on the list, use tasksel with the option --task-desc and the corresponding task. If you want to list all packages that belong to the “mail-server” task, use tasksel in combination with the option --task-packages.
To install all packages of a standard application, use the subcommand install. This requires root permissions.
8. tee
The Linux tee command is used to double the output of a program. One output is passed to the standard output, and another is written to the file given with the tee command.
tee [OPTIONS] FILE
bash
tee is usually used in combination with the redirection operator Pipe (|).
ls | tee example.txt
bash
9. time
Use the command time according to the following pattern to identify the runtime of programs that you’ve started over the terminal.
time [OPTIONS] Command [ARGUMENTS]
bash
10. tr
Use tr to delete a desired character set or replace it with another. To do this, tr reads the data stream of the standard input (e.g. a file) and writes it to the standard output according to the desired modification. If a character set is to be replaced by another, then tr is used with two arguments.
tr OPTION CHARACTERSET1 CHARACTERSET2
bash
The second argument (CHARACTERSET2) replaces the first (CHARACTERSET1). If you want to delete a character sequence, use tr with the option -d and enter the set to be deleted as the argument.
tr -d CHARACTERSET
bash
The command line program is usually used in combination with redirection operators (< and >) to make modifications to files.
tr 'a-z' 'A-Z' < example1.txt > example2.txt
bash
tr reads out the content of the example1.txt file, replaces the lower-case letters a through z with upper-case letters, and writes the output in the example2.txt file.
11. wall
The command line program wall allows you to send a message to all users registered on a system. To send a communication, start the program with the following call:
wall
bash
Confirm the program call with [Enter] and enter your message. Then confirm again with [Enter] and send with the key combination [CTRL] + [D]. All users registered on the system receive your message as a broadcast in the terminal. It is worth noting that in order to be able to receive communications, you have to provide other users with a write access to your terminal. For this, use the command mesg:
If you want to send file content to all registered users, use wall in combination with an input redirection and the respective file name:
wall < FILENAME
bash
12. watch
The command line program watch allows you to set a command to run at regular intervals. The program call is based on the following syntax:
watch [OPTIONS] COMMAND
bash
The time interval at which the command given in watch will be run is defined with the option -n SECONDS. End watch with the key combination [CTRL] + [C].
13. wc
The Linux wc command (short for word count) outputs the number or lines, words, letters, characters, and/or bytes of a text file, by request. The overall syntax of the command reads:
wc [OPTIONS] FILE
bash
If wc is called without options, the output corresponds to the LINES WORDS CHARACTERS FILE pattern. For a filtered output, the command line program supports the options: -l (lines), -c (bytes), -m (characters), -L (length of the longest line), and -w (words).
14. xargs
The Linux xargs command allows you to transfer the output of a previous command to a new command as an argument. Generally, this is used with the Pipe (|) as a diversion operator. Use xargs according to the following syntax:
COMMAND1 | xargs [OPTIONS] COMMAND2
bash
xargs can be used in combination with the command find, for example. In the following example, find identifies all files in the current directory that fit the search term *.tmp, and outputs their names to the standard output. There, the file names of xargs are accepted and passed as arguments to the command rm.
find . -name '*.tmp' | xargs rm
bash
The overview presented here doesn’t claim to be complete, but includes basic Linux commands with selected application examples for everyday work with unix-like operating systems. A comprehensive description of the command line programs presented here, as well as all other commands, can be found in your operating system’s manual. An online version of these help-and-documentation pages are available via the Linux man-pages project by Michael Kerrisk.
Was this article helpful?
We use cookies on our website to provide you with the best possible user experience. By continuing to use our website or services, you agree to their use. More Information.
Page top