Basic Linux commands. Cool Linux Commands


It's Friday, which means you can relax a little. This collection features 7 fun (and not so fun) commands that can be executed in the Linux terminal. Some are used as jokes, some are very useful.

cal - calendar in the terminal

Team cal displays a calendar in the terminal.

If you run it without parameters, the calendar for the current month is displayed:

You can specify the year, then we get a calendar for the whole year:

sl - train in the terminal

sl means Steam Locomotive - steam locomotive. The command was created for those who enter the command incorrectly ls(this command displays a list of files).

By command sl A steam locomotive passes through the terminal.

Install on Ubuntu:

Sudo apt install sl

rev - everything is the other way around

Team rev outputs everything you type in the terminal, but in reverse (from the word rev erse):

figlet - inscription

Team figlet displays in large letters the inscription that you indicated to it. The inscription is displayed in ASCII characters.

Installation on Ubuntu:

Sudo apt install filet

Figlet website

banner - banner

Team banner, as well as figlet, displays in the terminal in capital letters the characters that you specified to it. Only the first 10 characters are displayed.

Installation on Ubuntu:

Sudo apt install sysvbanner

Banner Penguin

aafire - fire in the terminal

Team aafire for those who want to see fire in their terminal, ASCII fire.

Installation on Ubuntu:

Sudo apt install libaa-bin

w is the shortest command

Team w is notable for the fact that it shortest command in Linux.

The w command displays information about the users currently using the system.

For each user, his name is displayed, information about what command line the user is using (shell), login time and idle time, and some other data.

In the first line that the command outputs w, shows the current time, uptime (uptime - system operating time), the number of users currently working and the average system load averages for the last 1, 5 and 15 minutes.

Almost all teams have additional options. To get more information about each command, run in a terminal

  1. && . Strictly speaking, this is not a team. 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.
  2. alias Assigns names you create to long commands that you can't remember. Enter the alias long_command short_command.
  3. 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 located there.
  4. clear. Clears the terminal window of all messages.
  5. history. Displays all the commands you have recently entered. Additionally, you can switch between recent commands using the Up and Down keys. If you do not want the command you entered to be written down, put a space in front of it like this: your_command.
  6. man. Displays a guide to programs and commands. Type man package_name or man your_command.
  7. whatis. Displays a brief description of a program. Enter the command and the program name whatis package_name.

To perform many actions on the system, such as installing and uninstalling programs, you will need administrator rights, or the superuser root as it is called in Linux.

  1. sudo This command will give you superuser rights. Type sudo before the command you want (for example, sudo apt upgrade) to run it as an administrator. The system will ask you for your password.
  2. sudo su . After this command, all commands you enter will be executed as the superuser until you close the terminal. Use it if you need to run a lot of commands with administrator rights.
  3. sudo gksudo . Command to run a GUI application with administrator rights. For example, if you want to move or change system files, type sudo gksudo nautilus (indicate the file manager you use).
  4. sudo!! . This command will run the previously entered command with administrator rights. Useful if you typed the command without sudo .

Do not execute commands as superuser that you do not understand.

Installing and uninstalling applications in Linux is performed by package managers. In Ubuntu the package manager is called apt, in Fedora - dnf, in Arch and Manjaro - pacman. They download applications from online repositories, package sources. Commands should be given to them with superuser rights.

apt (Debian/Ubuntu/Mint)

  1. sudo apt install package_name. Install the required package.
  2. sudo apt-add-repository repository_address. Add a third-party repository.
  3. sudo apt update . Update package information.
  4. sudo apt upgrade . Update all packages to the latest (perform after apt update).
  5. sudo apt remove package_name. Remove unnecessary package.
  6. sudo apt purge package_name. Remove an unnecessary package with all dependencies if you want to free up more space.
  7. sudo apt autoremove . Remove all unnecessary dependencies, orphan packages and other garbage.

dnf (Red Hat/Fedora/CentOS)

  1. sudo dnf install package_name. Install the required package.
  2. sudo dnf config-manager --add-repo repository_address. Add a third-party repository.
  3. sudo dnf upgrade . Update all packages to the latest ones.
  4. sudo dnf remove package_name. Remove unnecessary package.
  5. sudo dnf autoremove . Remove all unnecessary dependencies.

pacman (Arch/Manjaro)

  1. sudo pacman -S package_name. Install the required package.
  2. sudo yaourt -S package_name. Install a package from AUR if it is not in the main repository.
  3. sudo pacman -Sy . Update package information.
  4. sudo pacman -Syu . Update all packages to the latest ones.
  5. sudo pacman -R package_name. Remove unnecessary package.
  6. sudo pacman -Rs package_name. Remove an unnecessary package with all dependencies.

You can install and remove several 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 don't know its exact name, type the first few letters of the package name and press Tab twice. The package manager will show all packages whose names start with the same name.

  1. kill. This command is used to forcefully terminate processes. You need to enter kill PID_process. The PID of a process can be found by typing top .
  2. xkill. Another command to end processes. Enter it, then click on the window you want to close.
  3. killall. Kills processes with a specific name. For example, killall firefox.
  4. top. Displays a list of running processes, sorted depending on CPU resource consumption. A kind of terminal “System Monitor”.

Viewing and editing files

  1. cat. When the command is used with a single text file (like this: cat file_path), it displays its contents in a terminal window. If you specify two or more files, cat path_to_file_1 path_to_file_2 , it will merge them. If you enter cat file_path_1 > new_file, it will merge the contents of the specified files into a new file.
  2. chmod. Allows you to change file permissions. Can be useful if you want to make changes to a system file.
  3. chown. Changes the owner of a file. Must be executed with superuser rights.
  4. file. Displays information about the specified file.
  5. nano . Opens a simple text editor. You can create a new text file or open an existing one: nano file_path.
  6. rename. Renames a file or several files. The command can also be used for files by mask.
  7. touch. Changes the date the specified file was last opened or modified.
  8. wget. Downloads files from the Internet into a terminal folder.
  9. zip. Unpacks and compresses archives.

Creating and deleting files and folders

  1. mkdir. Creates a new folder in the current terminal folder or in the specified folder: mkdir folder_path.
  2. rmdir. Deletes the specified folder.
  3. rm. Deletes files. It can delete both an individual file and a group that meets certain criteria.

Copying and moving files

  1. 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.
  2. mv. Moves a file from one folder to another. You can specify a name for the file to be moved. Funnily enough, in Linux this command can also be used to rename files. Just specify the same folder where the file is located and a different name.

Search files

  1. find . Search files by specific criteria, such as name, type, size, owner, creation and modification date.
  2. grep. Search for text files containing specific strings. The criteria are very flexible.
  3. locate. Searches for files and folders whose names match the query and displays their paths in the file system.

  1. lsblk. This command shows you what drives you have 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.
  2. mount Mounts drives, devices, or file systems so you can work with them. Typically, devices will connect automatically as soon as you click on them in the file manager. But sometimes you may need to mount something manually. You can connect anything: disks, external drives, partitions and even ISO images. This command must be executed with superuser rights. To mount an existing disk or partition, enter mount sdX .
  3. umount. Dismounts file systems. The umount sdX command will mount the external media's file system so you can eject it.
  4. dd. This command copies and converts files and partitions. 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 erase the contents of the specified media with zeros so that the information cannot be recovered. And dd if=~/Downloads/ubuntu.iso of=/dev/sdX bs=4M will make bootable media from the distribution image you downloaded.

Linux Commands for User Management

  1. useradd. Registers a new user. Enter useradd username and the user will be created.
  2. userdel. Deletes the user's account and files.
  3. usermod. Changes a user account. May move the user's home folder or set a date for the account to be locked.
  4. passwd. Changes account passwords. A regular user can only change the password for his own account; a superuser can change the password for any account.

Linux Commands for Network Management

  1. ip. Multifunctional team to work with the network. The ip address show command displays information about network addresses, ip route controls routing, and so on. By issuing the commands ip link set ethX up, ip link set ethX down, you can turn connections on and off. The ip command has many uses, so it's best to read the manual before using it, or type ip --help
  2. ping. Shows whether you are connected to the network and helps determine the quality of the connection.

And one more thing

Finally, the main Linux commands. They put a cow on the screen that can talk to you (don't ask what the developers use).

  1. cowsay anything. The cow will say what you tell it.
  2. fortune | cowsay. The cow will give out a smart (or not so smart) thought or quote.
  3. cowsay -l . Lists all animals that can be displayed in the terminal. In case you don't like cows.
  4. fortune | cowsay -f animal_from_list. The animal of your choice begins to spout quotes, sometimes relevant ones.
  5. sudo apt-get install fortunes fortune-mod fortunes-min fortunes-ru . Will force the entire zoo to speak Russian. Without this, animals quote Twain and Wilde.

These are not all Linux commands. If you need to know in detail the parameters and how to use Linux commands, you can use the built-in tutorial. Type man your_command or your_command --help .

You may think you're new to Linux, but you're actually not. There are 3.74 billion global Internet users, and all of them use Linux in some way since Linux servers power 90% of the Internet. Most modern routers run Linux or Unix, and super computers also mostly run Linux. If you have an Android smartphone, your operating system is built on the Linux kernel.

In other words, Linux is everywhere.


Image: Opensource.com

But there is a difference between using Linux technologies and using Linux itself. If you're interested in Linux, you might be interested in learning how to use the Linux Command Line Interface (CLI)

Below are the basic Linux commands that everyone needs to know. Each of them is simple and easy to remember. In other words, you don't have to be an advanced user to understand them.

Start mastering the Linux command line interface with these 10 essential commands.

1.ls

No, this is not a typographical error - I actually intended to lowercase the L. ls, or "list" is the number one command you need to know to use the Linux CLI. This list command functions in the Linux terminal to display all the major directories filed in the corresponding file system. For example this command:

ls /applications

shows every folder stored in the applications folder. You will use it to browse files, folders and directories.

All hidden files can be viewed using the command ls -a

2. cd

This command is used to change (or "change") a directory. This is how you move from one folder to another. Say you're in the Downloads folder, but you want to go to the Gym Playlist folder.

Just enter text CD Gym Playlist won't work because the shell won't recognize it and will report that the folder you're looking for doesn't exist. To open this folder you need to put a backslash.

The command should look like this:

cd Gym\ Playlist

To go back from the current folder to the previous one, you can type the folder name followed by cd... Think of two dots like the back button.

3.mv

This command transfers a file from one folder to another; mv means "to move". You can use this short command as if you were dragging a file into a folder on your Windows PC.

For example, if I create a file called testfile to demonstrate all the basic Linux commands, and I want to move it to the My Documents folder, I would issue this command:

mv /home/sam/testfile /home/sam/Documents/

The first part of the command ( mv) says I want to move the file, the second part ( home/sam/testfile) names the file I want to move, and the third part ( /home/sam/Documents/) specifies the location where I want to transfer the file.

4. Linux Hotkeys

This is more than one team, but I couldn't resist talking about them here. For what? Because they save time and help a lot in work.

CTRL+K Cuts text from the cursor to the end of the line

CTRL+Y Insert text

CTRL+E Moves the cursor to the end of the line

CTRL+A Moves the cursor to the beginning of the line

ALT+F Move to next space

ALT+B Move to previous space

ALT+Backspace Deletes the previous word

CTRL+W Trims the word behind the cursor

Shift+Insert Pastes text into the terminal

Ctrl+D Logs out

These commands are used in different ways. For example, imagine that you misspell a word in the text of a command:

sudo apt-get intall programname

You probably noticed that " install" is misspelled, so the command will not work. But the keyboard shortcuts make it easy to go back and fix it. If my cursor is at the end of the line I can click ALT+B twice to move the cursor to the location shown below using ^ symbol:

sudo apt-get^intall programname

Now we can quickly add the letter s for correction install. Very simple!

5.mkdir

This is the command you use to create a directory or folder in a Linux environment. For example, you can enter mkdir DIY into the directory for your DIY projects.

6. at

If you want to run a Linux command at a specific time, you can add at to the equation.

Behind the syntax at followed by the date and time at which you want to execute the command. Then the command prompt will be changed, at> so that you can enter the command or commands you want to run at the time you specify

For example:

at 4:08 PM Sat

at> cowsay "hello"

This will launch the program cowsay at 16:08 on Saturday.

7.rmdir

This command allows you to delete a directory via the Linux CLI.

For example:

rmdir testdirectory

Keep in mind that this command will not delete a directory that has files inside. This only works when deleting empty directories.

8.rm

If you want to delete files, rm a team is what is needed. It can delete files and directories.

To delete one file, enter rm testfile

to delete a directory and the files inside it, enter rm -r.

9.touch

Team touch, otherwise known as the command make file, allows you to create new, empty files using the Linux CLI. Much like a team mkdir to create directories, touch used to create files.

For example, touch test file will create an empty file called testfile.

10.locate

This command is used to search for a file on a Linux system. Similar to Windows search. This is very useful if you forget where you saved the file or what you named it.

For example, if you have a document about blockchain use cases but can't come up with a title, you can click on it locate -blockchain or you can search for “chaining uses” by separating words with an asterisk or asterisks (*).

For example:

locate -i*blockchain*use*cases*,

There are many other useful Linux CLI commands such as pkill team, and it's great if you start to understand what they do.

Here are some other useful commands for people who want to learn how to use the Linux terminal: man, apropos, sudo, su, chown, chmod, find, xargs, grep, sed, mount, less, stat

But these 10 simple and useful commands are essential to get started using the Linux command line.

Not every Linux user needs to know how to work on the command line. But sooner or later there will come a time when you need to perform some minimal actions in the terminal. The cases can be completely different - setting up the system, restoring, copying data in case of failure, and so on.

Therefore, I decided to compile this collection of commands for beginners in Linux that can be useful to everyone.

1.ls

Team ls(if executed without arguments) is used to display a list of files in the current directory.

To list files in a directory /home/vasya/.ssh do:

Ls /home/vasya/.ssh

2. cd

Team CD used to navigate through the directory tree (move to another folder).

For example, to go to the directory /home/vasya/.local need to be done

Cd /home/vasya/.local

3.mv

Team mv used to move (or rename) files and directories.

For example, to move a directory /home/vasya/documents to the directory /home/vasya/secret do:

Mv /home/vasya/documents /home/vasya/secret

4.cp

Team cp creates a copy of a file or directory.

To copy a file messages.log to file messages.log.bak do:

Cp messages.log messages.log.bak

To copy a directory, you need to add an argument after the command -r. For example, let's copy the directory drivers V display-drivers:

Cp -r drivers display-drivers

5. sudo

Team sudo used to execute other commands as superuser. But you need to use it carefully, as it can damage the system.

For example, if you try to create a copy of a file in the "system" directory /etc, you will receive a warning Permission denied. Therefore, in this case the command must be executed as a superuser, for example:

Sudo cp /etc/X11/xorg.conf /etc/X11/xorg.conf.bak

6.touch

Team touch you can create an empty file.

For example, let's create an empty file path.dat:

Touch path.dat

7.find

Team find designed to search for files. Yes, this is not the simplest command, but knowing it is very useful. To begin with, just remember how to search for files and directories by name or by mask (part of the name).

For example, let's find in the current directory all files (and directories) whose names begin with document, and ends odt(these may be files document-history.odt, document1.odt, document.odt, document-linux.odt):

Find. -name "document*.odt"

Explanation: the dot symbol after the command means that we are searching in the current directory (and in all directories within the current one). After the argument -name The file name or mask (pattern) by which we are searching is written in quotes. The asterisk symbol in a mask means that any symbols can replace the asterisk.

8. cat

Team cat displays the contents of the specified file on the screen.

For example, to view the contents of a file /var/log/auth.log do:

Cat /var/log/auth.log

9.nano

In fact nano This is a console text editor. But sometimes, this is one of the few ways to edit a file from the command line (for example, when the GUI does not load or is missing).

For example, to create or edit an existing file ftp.cfg do:

Nano ftp.cfg

A text editor will open. Make changes to the file. Then press the keyboard shortcut Ctrl+x and enter y to save changes and exit (or enter n to close the file without saving changes).

10.mkdir

Team mkdir creates an empty directory.

For example, to create a backup directory, run:

Mkdir backup

rm and rmdir

These are the eleventh teams in my selection, since I believe that beginners need to learn about them last. Team rm serves to delete files. rmdir is intended for deleting directories.

For example, delete the file veryimportantfile.dat:

Rm veryimportantfile.dat

To delete a directory, use the command command rmdir. For example, let's delete the directory photos:

Rmdir photos

apt or apt-get

And one more important command for those who use Ubuntu. apt is a package manager that is used to install and remove programs (packages), and update the system.

For example, to install the Midnight Commander console file manager, run:

Sudo apt install mc

If apt is not available, then use apt-get:

Sudo apt-get install mc

Something else?

I'm sure I haven't written a lot of important commands yet. So please add others in the comments. must have commands that you think will be very useful for beginners.







2024 gtavrl.ru.