Linux Commands

Inhalt

Command Overview
Commands by Category
Disks and Partitions
File Compression
File Permissions
Files and Directories
Hardware
Navigation
Network
Processes
Search
Shell Special Commands
System Information
Users and Groups

Depending on the distribution, some commands may need to be installed first, e.g. whois or dig.

Commands can accept many more parameters than listed here. All available parameters can be taken from the help with man [COMMAND]. The parameters can also be displayed with [COMMAND] --help or [COMMAND] -h.

Some commands or arguments require execution with the command sudo.

Command Overview

CommandDescription
!!Execute the last command !!!
> [FILE]Create empty file !!!
badblocks -s /dev/[DEVICE]Drive check sudo
calShows current month calendar
cat /etc/groupShows all groups
cat /etc/passwdShows all users
cat /proc/cpuinfoCPU information
cat [FILE]Output file content
cat [SOURCE] >> [TARGET]Append file content to another file
cd ..Go to parent directory
cd [DIRECTORY]Go to a directory
cd ~Go to home directory
chmod [RIGHTS] [FILE]Change file permissions sudo !!!
chown [USER] [FILE]Change file owner sudo !!!
chown [USER]:[GROUP] [FILE]Change file owner and group sudo !!!
cp -r [SOURCE] [DESTINATION]Copy a directory
cp [SOURCE] [DESTINATION]Copy a file
dateShows current date and time
date -RShows current date and time (RFC-5322)
date -uShows current date and time (UTC)
df -hShows free and used disk space
dig [HOST] ANYShow DNS information
dmesgBootup messages sudo
dmidecodeSystem information sudo
dmidecode --dump-bin [FILE]System information (dump to file) sudo
dmidecode --from-dump [FILE]System information (read from file)
du -ah [PATH]Shows disk usage
exitExit the current shell
fdisk -lShows partitions sudo !!!
find [PATH] -name [EXPRESSION]Search for files in a directory
findmntList all file systems
free -hMemory usage
gpg -c [FILE]Encrypt a file
gpg -d [FILE]Decrypt a file
grep -Hnir [TERM] [DIRECTORY]Recursive search in a directory
grep -i [TERM] [FILE]Search in a file
groupadd [GROUP]Create new group sudo
groupdel [GROUP]Remove a group sudo !!!
groupsShows current groups
gzip -d [FILE]Decompress file with GNU ZIP
gzip -k [FILE]Compress file with GNU ZIP
hdparm -g /dev/[DEVICE]Drive geometry sudo !!!
hdparm -i /dev/[DEVICE]Drive information sudo !!!
hdparm -tT /dev/[DEVICE]Drive read-speed test sudo !!!
head [FILE]Shows the first 10 lines of a file
hostnameShows the system hostname
hostname -iShows the system IP address
idShows current user information
id -unShows the own user name
id [USER]Shows user information
ip addrList IP addresses and network interfaces
ip routeShows routing table
kill [PID]Kill a process by its PID !!!
killall [NAME]Kill all processes with a given name
lastShows last logged in users
last rebootShows system reboot history
less [FILE]Shows file content
ln -s [TARGET] [NAME]Create a symbolic link
locate [TERM]Search for files
lsList files in directory
ls -laList all files in directory
lsblkBlock devices
lsofList all open files
lspciPCI devices
lspci -tvPCI devices (tree)
lspci -vPCI devices (verbose)
lsusbUSB devices
lsusb -tvUSB devices (tree)
lsusb -vUSB devices (verbose)
mkdir [DIRECTORY]Create new directory
more [FILE]Shows file content
mv [SOURCE] [DESTINATION]Rename or move a file or directory !!!
ping [HOST]Ping a host
pkill [NAME]Kill a process by its name !!!
pmap [PID]Shows memory map o a process
ps -auxShows all processes
pstreeShows processes (tree)
pwdShows current directory path
rm -r [DIRECTORY]Remove directory !!!
rm [FILE]Remove file !!!
ss -apShows open ports
tail [FILE]Shows the last 10 lines of a file
tar cf [TARGET] [FILES]Compress files with TAR
tar czf [TARGET] [FILES]Compress files with TAR and GNU ZIP
tar xf [FILE]Extract files with TAR
topShows processes (in real-time)
touch [FILE]Change file time !!!
traceroute -I [HOST]Trace route to a host
uname -aShows system and kernel information
uptime -pShows system running time
uptime -sShows system start time
useradd [USER]Create new user sudo
userdel [USER]Remove user sudo !!!
usermod -aG [GROUP] [USER]Add a user to groups sudo !!!
usersShows logged in users
wShows logged in users and their activity
wc [FILE]Count lines, words and bytes of a file
whoShows logged in users
who -bShows system boot time
whoamiShows the own user name
whois [HOST]Get whois information

Did you like my page, one of my freeware applications or online tools?

Then, please donate via PayPal in order to help keeping its content free - each amount is welcome!

Read more about support options...

Commands by Category

Disks and Partitions

df -h
Shows the free and used space on all file systems.
du -ah [PATH]
Shows the disk usage for the specified [PATH]. Without a path, the current path is used.
fdisk -l
Lists all partitions, sizes and types.
Execute with sudo / Caution when using
findmnt
Lists all file systems.

File Compression

gzip -d [FILE]
Decompresses a [FILE] with GNU ZIP.
gzip -k [FILE]
Compresses a [FILE] with GNU ZIP and store the compressed file as "[FILE].gz". Without the option "-k", the original file will be removed.
tar cf [TARGET] [FILES]
Compresses one or more [FILES] with TAR and store it as [TARGET] file (e.g. "archive.tar").
tar czf [TARGET] [FILES]
Compresses one or more [FILES] with TAR and GNU ZIP and store it as [TARGET] file (e.g. "archive.tar.gz").
tar xf [FILE]
Extracts files from a TAR [FILE].

File Permissions

chmod [RIGHTS] [FILE]
Changes the file permissions for a [FILE]. The [RIGHTS] can be entered as octal code (digits 0-7) in the order owner-group-others. Rights: 4=read, 2=write, 1=execute, 0=none. Examples: 777=all rights for all users, 644=read and write for owner, read only for all other.
Execute with sudo / Caution when using
chown [USER] [FILE]
Changes the owner of the [FILE] to the specified [USER].
Execute with sudo / Caution when using
chown [USER]:[GROUP] [FILE]
Changes the owner and the [GROUP] of the [FILE] to the specified [USER].
Execute with sudo / Caution when using

Files and Directories

> [FILE]
Creates a new empty [FILE]. If the [FILE] exists, it's size will be set to 0.
Caution when using
cat [FILE]
Outputs the content of a [FILE].
cat [SOURCE] >> [TARGET]
Appends the content of one or more [SOURCE] files to a [TARGET] file.
cp -r [SOURCE] [DESTINATION]
Copies a [SOURCE] directory to a [DESTINATION] directory with its entire content.
cp [SOURCE] [DESTINATION]
Copies a [SOURCE] file to a [DESTINATION] file or directory.
gpg -c [FILE]
Encrypts a [FILE]. Password will be prompted.
gpg -d [FILE]
Decrypts a [FILE].
head [FILE]
Shows the first 10 lines of a [FILE].
less [FILE]
Shows the content of a [FILE]. Lines and/or pages are scrollable.
ln -s [TARGET] [NAME]
Creates a symbolic link with the given [NAME] to a [TARGET] file or directory.
mkdir [DIRECTORY]
Creates a new [DIRECTORY].
more [FILE]
Shows the content of a [FILE]. Lines and/or pages are scrollable.
mv [SOURCE] [DESTINATION]
Moves a [SOURCE] file or directory to a new [DESTINATION] or rename it.
Caution when using
pwd
Prints full path of the current working directory.
rm -r [DIRECTORY]
Removes a [DIRECTORY] with its entire content.
Caution when using
rm [FILE]
Removes the specified [FILE].
Caution when using
tail [FILE]
Shows the last 10 lines of a [FILE].
touch [FILE]
Changes the access and modification time of a [FILE] to the current time. touch creates the [FILE], if it does not exist.
Caution when using
wc [FILE]
Counts lines, words and bytes in the content of a [FILE].

Hardware

badblocks -s /dev/[DEVICE]
Checks a [DEVICE] for unreadable blocks.
Execute with sudo
cat /proc/cpuinfo
Shows CPU information.
dmesg
Shows messages from system bootup.
Execute with sudo
dmidecode
Shows information about BIOS, system, mainboard and chassis.
Execute with sudo
dmidecode --dump-bin [FILE]
Dumps information about BIOS, system, mainboard and chassis in a binary file.
Execute with sudo
dmidecode --from-dump [FILE]
Shows information about BIOS, system, mainboard and chassis from a binary dump file.
free -h
Shows free and used memory.
hdparm -g /dev/[DEVICE]
Shows drive geometry of the specified [DEVICE].
Execute with sudo / Caution when using
hdparm -i /dev/[DEVICE]
Shows drive information about the specified [DEVICE].
Execute with sudo / Caution when using
hdparm -tT /dev/[DEVICE]
Performs a read-speed test for the specified [DEVICE].
Execute with sudo / Caution when using
lsblk
Shows information about block devices.
lspci
Shows information about PCI devices.
lspci -tv
Shows information about PCI devices as tree.
lspci -v
Shows verbose information about PCI devices.
lsusb
Shows information about USB devices.
lsusb -tv
Shows information about USB devices as tree.
lsusb -v
Shows verbose information about USB devices.

Navigation

cd ..
Goes to the parent directory.
cd [DIRECTORY]
Goes to the specified [DIRECTORY].
cd ~
Goes to the users hone directory.

Network

dig [HOST] ANY
Shows DNS information for a [HOST].
ip addr
Shows addresses assigned to all network interfaces.
ip route
Shows the routing table.
ping [HOST]
Performs a ping to a given [HOST].
ss -ap
Shows a list with all open sockets, including the ports and the processes using these sockets.
traceroute -I [HOST]
Traces the route to a [HOST] per ICMP ECHO.
whois [HOST]
Shows whois information for a [HOST].

Processes

kill [PID]
Kills a process with the specified [PID].
Caution when using
killall [NAME]
Kills all processes with the specified [NAME].
lsof
Lists all files opened by running processes.
pkill [NAME]
Kills a process with the specified [NAME].
Caution when using
pmap [PID]
Shows the memory map of the process specified by its [PID].
ps -aux
Shows all processes running on the system.
pstree
Shows running processes as tree.
top
Shows running processes in real-time.

Search

find [PATH] -name [EXPRESSION]
Searches in a given [PATH] for file names with the specified [TERM] (incl. placeholders like "*" and "?").
grep -Hnir [TERM] [DIRECTORY]
Searches recursive for a case-invariant [TERM] in all files of a [DIRECTORY] and display the filename and line number.
grep -i [TERM] [FILE]
Searches for a [TERM] in a [FILE].
locate [TERM]
Search for file names with a given [TERM].
ls
Lists files in the current directory.
ls -la
Lists all files in the current directory with additional information.

Shell Special Commands

!!
Executes the last command.
Caution when using
exit
Exits the current shell.

System Information

cal
Shows a calendar for the current month. The parameter "-w" adds week numbers.
date
Shows the current date and time.
date -R
Shows the current date and time in the RFC-5322 format.
date -u
Shows the current date and time as Coordinated Universal Time (UTC).
hostname
Shows the hostname of the system.
hostname -i
Shows the IP address of the system.
last reboot
Shows a list with the last system reboots.
uname -a
Shows system and kernel information like operating system name and version, machine name and kernel release.
uptime -p
Shows how long the system has been running.
uptime -s
Shows the date and time since the system is running.

Users and Groups

cat /etc/group
Shows the file "/etc/group" with all group names and group IDs.
cat /etc/passwd
Shows the file "/etc/passwd" with all user names and user IDs.
groupadd [GROUP]
Creates a new group with the specified [GROUP] name.
Execute with sudo
groupdel [GROUP]
Removes the group specified by [GROUP].
Execute with sudo / Caution when using
groups
Shows the current group names.
id
Shows user and group information for the current user.
id -un
Shows the own user name. Same as "whoami".
id [USER]
Shows user and group information for the specified [USER].
last
Shows a list with the last logged in users.
useradd [USER]
Creates a new user with the specified [USER] name.
Execute with sudo
userdel [USER]
Removes the user specified by [USER].
Execute with sudo / Caution when using
usermod -aG [GROUP] [USER]
Adds a [USER] to the specified [GROUP]. Without option "-a" all other groups of the user will be replaced with the new group!
Execute with sudo / Caution when using
users
Shows the currently logged in users.
w
Shows a list with the currently logged in users and their activity.
who
Shows a list with the currently logged in users.
who -b
Shows the date and time of the last system boot.
whoami
Shows the own user name. Same as "id -un".

Did you like my page, one of my freeware applications or online tools?

Then, please donate via PayPal in order to help keeping its content free - each amount is welcome!

Read more about support options...




This website use cookies and process data. Information on data processing and the possibility of refusing it can be found in the privacy policy. Ok