Table of contents:
- Linux commands for navigating the terminal
- Linux commands for obtaining superuser rights
- Linux commands for managing the package manager
- Linux commands for managing processes
- Linux commands for managing files
- Linux commands for working with partitions
- Linux commands for system management
- Linux commands for user management
- Linux commands for network management
- And something else
2024 Author: Malcolm Clapton | [email protected]. Last modified: 2024-01-19 14:05
You can do almost anything in the Linux terminal: configure the system, install and uninstall applications, manage disks and files, and even talk to cows.
Linux commands for navigating the terminal
-
&&
… Strictly speaking, this is not a command. If you want to execute several commands at once, put a double ampersand between them like this:
first_command && second_command
- … The terminal will execute the commands in order. You can enter as many commands as you like.
-
alias
… Assigns the names you create to long commands that you cannot remember. Enter
alias command-long short-command
- .
-
cd
… Changes the current terminal folder. When you start the terminal, it uses your home folder. Enter
cd folder_address
- , and the terminal will work with the files that are there.
-
clear
- … Clears all messages from the terminal window.
-
history
… Displays all the commands you have recently entered. In addition, you can switch between recent commands using the Up and Down keys. If you don't want the command you entered to be written down, put a space before it like this:
your team
- .
-
man
… Displays a guide to Linux programs and commands. Enter
man package_name
or
man your_command
- .
-
whatis
… Displays a short description of a program. Enter the command and the name of the program
whatis package_name
- .
Linux commands for obtaining superuser rights
To perform many actions on the system, for example, to add and remove programs, you need administrator rights, or the superuser root, as it is called in Linux.
-
sudo
… This command will give you superuser rights. Enter
sudo
before the command you want (e.g.
sudo apt upgrade
- ) to run it as an administrator. The system will ask you for a password.
-
sudo su
- … After this command, all the commands you enter will be executed on behalf of the superuser until you close the terminal. Use it if you need to execute a lot of commands with administrator rights.
-
sudo gksudo
… Command to run a GUI application as an administrator. For example, if you want to move or modify system files, enter
sudo gksudo nautilus
- (specify the file manager you are using).
-
sudo !!
… This command will run the previously entered command with administrator privileges. Useful if you typed a command without
sudo
- .
Do not execute commands on behalf of the superuser that you do not understand.
Linux commands for managing the package manager
Installing and uninstalling applications on Linux is done by package managers. Ubuntu and Debian call the package manager apt, Fedora calls dnf, Arch and Manjaro call pacman. They download applications from online repositories, package sources. Commands should be given to them with superuser rights.
apt (Debian / Ubuntu / Mint)
-
sudo apt install package_name
- … Install the required package.
-
sudo apt-add-repository repository_address
- … Add a third party repository.
-
sudo apt update
- … Update package information.
-
sudo apt upgrade
… Update all packages to the most recent (run after
apt update
- ).
-
sudo apt remove package_name
- … Remove unnecessary package.
-
sudo apt purge package_name
- … Remove an unnecessary package with all dependencies if you want to free up more space.
-
sudo apt autoremove
- … Remove all unnecessary dependencies, orphaned packages and other junk.
dnf (Red Hat / Fedora / CentOS)
-
sudo dnf install package_name
- … Install the required package.
-
sudo dnf config-manager --add-repo repository_address
- … Add a third party repository.
-
sudo dnf upgrade
- … Update all packages to the most recent.
-
sudo dnf remove package_name
- … Remove unnecessary package.
-
sudo dnf autoremove
- … Remove all unnecessary dependencies.
pacman (Arch / Manjaro)
-
sudo pacman -S package_name
- … Install the required package.
-
sudo yaourt -S package_name
- … Install a package from the AUR if it is not in the main repository.
-
sudo pacman -Sy
- … Update package information.
-
sudo pacman -Syu
- … Update all packages to the freshest.
-
sudo pacman -R package_name
- … Remove unnecessary package.
-
sudo pacman -Rs package_name
- … Remove unnecessary package with all dependencies.
You can install and uninstall multiple packages at once by simply listing them separated by a space.
sudo apt install firefox clementine vlc
If you want to install a package but do not know its exact name, enter the first few letters of the package name and press Tab twice. The package manager will show all packages that start with the same name.
Linux commands for managing processes
-
kill
… This command is used to force the termination of processes. You need to enter
kill process_PID
… The PID of the process can be found by entering
top
- .
-
xkill
- … Another command to terminate processes. Enter it, then click on the window you want to close.
-
killall
… Kills processes with a specific name. For example,
killall firefox
- .
-
top
- … Displays a list of running processes, sorted based on CPU consumption. A kind of terminal "System Monitor".
Linux commands for managing files
Viewing and modifying files
-
cat
… When the command is used with one text file (like this:
cat path_to_file
), it displays its contents in a terminal window. If you specify two or more files,
cat path_to_file_1 path_to_file_2
she will glue them together. If we introduce
cat path_to_file_1> new_file
- , it will merge the contents of the specified files into a new file.
-
chmod
- … Allows you to change the file permissions. This can be useful if you want to make changes to the system file.
-
chown
- … Changes the owner of the file. Should be run with superuser rights.
-
file
- … Displays information about the specified file.
-
nano
… Opens a simple text editor. You can create a new text file or open an existing one:
nano path_to_file
- .
-
rename
- … Renames a file or multiple files. The command can also be used for mass renaming of files by mask.
-
touch
- … Changes the date when the specified file was last opened or modified.
-
wget
- … Downloads files from the internet to a terminal folder.
-
zip
- … Unpacks and compresses archives.
Creating and deleting files and folders
-
mkdir
… Creates a new folder in the current terminal folder or in the specified folder:
mkdir folder_path
- .
-
rmdir
- … Deletes the specified folder.
-
rm
- … Deletes files. It can delete both a separate file and a group corresponding to certain characteristics.
Copying and moving files
-
cp
… Creates a copy of the specified file in the terminal folder:
cp path_to_file
… Or you can specify the destination
cp path_to_file path_to_copy
- .
-
mv
- … Moves a file from one folder to another. You can specify a name for the relocatable file. Funnily enough, on Linux, this command can be used to rename files as well. Just specify the same folder where the file is located and a different name.
Search for files
-
find
- … Search for files by specific criteria such as name, type, size, owner, creation and modification date.
-
grep
- … Search for text files containing specific strings. The criteria are very flexible.
-
locate
- … Search for files and folders whose names match the query and display their paths in the file system.
Linux commands for working with partitions
-
lsblk
- … This command demonstrates what disks are on your system and what partitions they are divided into. The command also displays the names of your partitions and drives, in the format sda1, sda2, and so on.
-
mount
… Mounts Linux drives, devices or file systems for you to work with. Usually devices are connected automatically as soon as you click on them in the file manager. But sometimes you may need to mount something manually. You can mount anything: disks, external drives, partitions, and even ISO images. This command must be executed with superuser rights. To mount an existing disk or partition, type
mount sdX
- .
-
umount
… Dumps filesystems. Command
umount sdX
- will unmount the file system of the external media so you can eject it.
-
dd
… This command copies and converts files and sections. It has many different uses. For example,
dd if = / dev / sda of = / dev / sdb
will make an exact copy of the sda partition on the sdb partition.
dd if = / dev / zero of = / dev / sdX
will overwrite the contents of the specified media with zeros so that the information cannot be restored. A
dd if = ~ / Downloads / ubuntu.iso of = / dev / sdX bs = 4M
- will make bootable media from the distribution image you downloaded.
Linux commands for system management
-
df
- … Displays the size of your disk and how much free space is left on it.
-
free
- … Displays the amount of available and used RAM.
-
uname
… Displays system information. If you enter
uname
the terminal will only report Linux. But the team
uname -a
- displays information about the computer name and kernel version.
-
uptime
- … Tells how long your system has been running.
-
whereis
- … Displays the location of the executable file for the desired program.
-
whoami
- … Calls the username.
Linux commands for user management
-
useradd
… Registers a new user. Enter
useradd username
- and the user will be created.
-
userdel
- … Removes user account and files.
-
usermod
- … Changes the user account. Can move the user's home folder or set a date when the account will be locked.
-
passwd
- … Changes account passwords. A regular user can change the password of only his own account, the superuser can change the password of any account.
Linux commands for network management
-
ip
… Multifunctional team for working with the network. Command
ip address show
displays information about network addresses,
ip route
manages routing and so on. Giving commands
ip link set ethX up
,
ip link set ethX down
you can turn connections on and off. The team
ip
many uses, so before using it it is better to read the manual or enter
ip --help
-
ping
- … Shows whether you are connected to the network and helps determine the quality of the connection.
And something else
Finally, there are the main Linux commands. They display a cow that can talk to you (don't ask what the developers are using).
-
cowsay whatever
- … The cow will say what you tell her.
-
fortune | cowsay
- … The cow will give out a smart (or not so) thought or quote.
-
cowsay -l
- … Lists all animals that can be displayed in the terminal. If you suddenly do not like cows.
-
fortune | cowsay -f animal_from_list
- … The animal of your choice begins to shower with quotes, sometimes appropriate.
-
sudo apt-get install fortunes fortune-mod fortunes-min fortunes-ru
- … Make the whole zoo speak Russian. Without this, animals are quoting Twain and Wilde in the original.
These are not all Linux commands. If you need to know in detail the options and how to use Linux commands, you can use the built-in tutorial. Dial
man your_command
or
your_command --help
Recommended:
20 useful Google Sheets templates for all occasions
Google Sheets is a free set of handy features for those who like to keep things under control. Try out-of-the-box solutions to make your life easier
14 multi-tools with AliExpress for all occasions
With pliers, knives, a hammer and even an ax: we found multitools for different budgets and with different functionality. Also available as a bracelet
25 new brilliant life hacks for all occasions
How to iron things without an iron, hide a bald spot or save flowers from fading while on vacation? We've found elegant ways to solve these and other problems
How your life will change if you remove almost all applications from your smartphone
Don't waste time installing another program on your smartphone that promises to make your life more convenient. Try going the other way around and uninstalling apps from those already installed. If not all, then at least some of them. The comfort in your life will really increase
How I almost died in Thailand and almost became a philosopher
Well, okay, I exaggerated "for great dramatic effect" (Goblin). Although I really felt bad. But first things first … It all started with the fact that my family and I went to Thailand for three months. Let me remind you that I wanted to leave my comfort zone and shake things up a bit.