Useful Terminal Commands
Table of Contents
Details
This is a selection of some useful and important terminal commands. Most modern Linux distributions ship with a graphic interface and you will not likely need to use any terminal commands. However, you may enjoy the simplicity of the command line, or may find yourself using a system without a GUI or may need a special command.
These commands should be compatible with the following GNU/Linux distributions. Click to show list.
- Arch
- Bazzite
- Cent OS / Rocky Linux / AlmaLinux
- Debian [8+]
- Fedora
- Mint
- openSUSE
- *buntu
Basics
Copy highlighted text from a terminal window
Ctrl + Shift + C
Paste text to a terminal window
Ctrl + Shift + V
Restart the OS
sudo reboot
Shutdown the machine
sudo shutdown now
or
sudo poweroff
Check the version of an installed package
packagename --version
This example is checking the version of python3:
testuser@testing-server:~$ python3 --version
Python 3.11.2
File Management
List files in the current directory
ls
List files and show more information
ls -lh
Change directories
cd directory_name
Move 'up' one directory
cd ..
Return to your user 'home' directory
cd
Make a new directory
mkdir new_directory_name
Copy a file
cp existing_filename new_filename
Move / Rename a file or directory
This example is moving/renaming a file
mv file_name.txt new_file_name.txt
This example is moving a directory into the "backup" directory
mv /server-folder/save-1 /backup/server-folder/save-1
Remove a file
Warning: be careful when removing files and directories.
rm filename
Remove a directory and the contents
rm -r directory_name
Remove a directory and the contents without prompts
rm -rf directory_name
Networking
Check your IP address(es)
ip a
Ping an address
ping examplesite.com
Interface information
ip link
DNS Lookup
nslookup examplesite.com
Trace route via 'My traceroute'
mtr examplesite.com
Administration
Check system boot time
systemd-analyze
Check how long it took each service to initialize
These times can take longer than the boot time.
systemd-analyze blame
Change a user's password
In this example replace user_name with the user you want modify the password for.
passwd user_name