Basic commands in the Linux console. Linux console commands

In Linux, any administrative task can be performed from the console. The ability to work from the console is a necessary experience for administering Linux. There are tools that allow you to avoid talking to the console, but with them you will be more limited in what you can do. Connecting to the console is easy and getting documentation for the commands is also easy. This article describes the simplest and most necessary commands to get started in the console.

Console connection

If your system boots in text mode (a common configuration for servers to receive console output from main processes), then you are already in the console when you log in. Typically on a Linux system you can get to additional consoles by pressing Ctrl keys+ Alt + (F1 – F6). Each console is a completely separate session on the system and can be used by different users at the same time.


This "multi-console" behavior is different from the "multi-desktop" behavior in Windows. In Linux, each console can be controlled by completely different users. For example, you can log in as root on the first console, and as joeuser on the second. Both consoles run different programs in the space of its user. In the same spirit different users can log in remotely Windows system. In this case, Linux provides a mainframe-like experience rather than a simple server or workstation.

If you work in graphic mode, then you can open a terminal to access the console window. There is usually a Terminal button on the desktop taskbar, or it can be found in the Program menu in System Tools. The terminal can also be opened from context menu(appears when you right-click on the desktop).

Teams

A lot is available from the console additional commands. Some of them are only really useful when writing scripts. Here are some of the ones you'll probably need. Don't forget that all commands and switches are case sensitive. -R is not the same as -r and will most likely produce a different result. Console commands almost always written in lowercase.

CD
To navigate through directories, use the familiar cd command. The main thing to remember is that where you are used to the backslash (\), Linux uses the forward slash (/). Backslash also occurs, but for a different reason - it indicates that the command will continue for next line. This is sometimes done for better readability when typing very long commands.
ls
A list of files in a directory is called with the ls command. There are several keys that can be used to change the appearance of the list:

ls -l Shows extended output including file sizes, date and time last change and attributes
ls -t Sorts files by time
ls -S Sorts files by size
ls -r When used in conjunction with one of the sort keys, changes the order of the output. ls -lt shows the newest files at the very top of the list. ls -lrt shows the newest files at the very bottom.
ls -h Readable. Uses friendly indicators k, M and G, which show the file size in human readable units, rather than displaying it in bytes.
ls -a Shows all files in a directory, even hidden ones

cp
Files are copied using the cp command. Main keys:

mv
The mv command is used to move and rename files.

cat
You can view files using the cat command. This command will output the contents of a file to another file, either to the screen or to the input of another command. cat is short for "concatenate", so you can use it to combine multiple files into one larger file.

more
The more command allows you to view information page by page.

less
To view a text file with the ability to scroll up and down and search by pattern, use the less command.

vi
The vi test editor is available in almost any UNIX-like environment. The version installed on Linux has a built-in tutorial, and once you get the hang of it, you can do some truly incredible things with just a few button presses. Vi is very convenient for editing files with passwords and configurations.

man
Documentation for a particular command can be seen using the man command. Man is short for manual(). The documentation is usually complete. You can learn more about the man command by typing:

info
info is similar to man except that it supports hyperlinks, which makes navigating the documentation easier.

What shell?

The command line shell is a layer separate from the operating system. The shell environment affects features such as editable command lines and scrollable histories. The shell also defines the syntax required to create functions in scripts. IN Linux scripts can contain loops and do more than just conditional statements, including many of the things you'd expect from a programming language.

The default shell is a different option for each user. Typically on Linux this is /bin/bash, but it could be something else. The man documentation for each shell is really very good, covering shells and how they work in detail. Select a shell from the list below and view its man page.

bash
The bash shell is a free version of the Bourne shell, the first Unix shell, plus many additional properties. Bash has editable command lines, a scrollable command history, and tab appending so you don't have to type long file names.

csh
The C shell uses a C-like syntax and borrows many features from the Bourne shell, but uses a different set of internal shell commands.

ksh
The Korn shell uses the same syntax as the Bourne shell and incorporates the user friendliness of the C shell. ksh is used in many installation scripts, so it should probably be on the system even if it is not the main shell.

tcsh
TC shell is an improved version of the C shell and is 100% compatible with it.

zsh
Z shell is an improved version of the Korn shell with many of the features of the bash shell.

One attractive feature of the Linux file system is file links. Thanks to them, a file can be visible in several places in the file system. However, on Linux, the link can be treated as a source file. The link can be executed, edited, accessed without doing anything unusual. Some applications in the system are a link to some executable file. When you make changes to a file via a link, you are actually editing the original. A link is not a copy. There are two types of links: hard and symbolic.

Hard link can only point to files in the same file system. It provides a link to the file's physical index (aka inode) in the file system. Hard links are not broken when the original is moved because they all point to the physical data of the file rather than its location in file structure. A file with a hard link does not require the user to have access rights to source file and does not show its location, which provides some security advantages. If you delete a file that has hard links, it will still remain until all links to it are deleted.

Symbolic link-- pointer to the file location in the file system. Symbolic links can span file systems and even point to files from a remote file system. A symbolic link points to the location of a source file, and to use it, the user must have permissions to that source file. If the original is deleted, then all symbolic links are broken. They will point to a non-existent file.

Both types of links can be created using the ln command.

Exit shell

In many cases, using the console requires less time and provides more options than graphics program. Moreover, any console task can be written into a script and thereby automated.

Leave your comment!

A novice user naturally begins to master OS Linux from the graphical interface. But after a while he decides to try working on the command line. Ultimately, almost everyone will be able to do this. This is a rather interesting and exciting process. Only in the command line does the full power of this operating system open. This review lists the most main commands.All this is in the reference manual - man, but at first you may not be able to use it manually. Follow the link. First, try simply typing the commands given below without additional parameters (of which there are quite a lot and can be found out by entering the “command -help” or “man command name”.

Please, if possible, correct or supplement this list in the comments. Many of the commands below are “Unix like”, which means that you can use them also, based on Unix operating systems systems, for example - Mac OS X, etc.

Teams:

  • login request from the user for a name and password (request from the system to the user) to log in to the system (by default, when entering a password, it is not displayed).
  • logout exits the current shell session.
  • startx command to launch the X Window graphical interface (not to be confused with the Windows system. Don't be afraid. This is not it :)).
  • shutdown stops the system and prevents file system corruption in the process, but is only used when running in console mode. When running in X Window mode, do not use.
  • halt quick and correct shutdown of the system.
  • poweroff correct shutdown of the system.
  • reboot correct shutdown with subsequent boot. Reboot.
  • vmstat provides information about processes, memory and CPU load.
  • su login to the administrator session, but you will have to enter a password. To exit this session, type exit and press ENTER.
  • apropos search for a string in the titles and titles of the documentation (additionally, enter a search word). Gives a list of everything found.
  • cal formatted calendar on current month(add y and there will be a calendar for the entire current year).
  • date displays current date and time, according to the kernel system clock.
  • oclock simple clock, which hang on the desktop (many additional parameters).
  • finger display information about the user whose name is specified in the command.
  • hostname The command displays the identifier of this network node (its name). root can change the node name to a new one.
  • hwclock your computer's built-in clock. To change the date and time and synchronize with the system clock, root privileges are required.
  • pwd displays the full path to the current directory.
  • tzselect launching a utility that allows you to select the time zone.
  • uname displays information about the used operating system(when you enter additional command parameters, it produces quite a lot of information).
  • uptime shows current time, session duration, number of users and processor load.
  • users displays short list users working in the system in this moment.
  • w detailed information about all users currently working and also simple login, etc. If you need one user, then specify the name in the parameter.
  • whatis Searches a database of manual pages and displays a short description.
  • who list of users currently working in the system.
  • whereiz finds files, pages reference guide for the specified command.
  • which shows the full path to the command executable.
  • whoami shows the current user ID working in this terminal.
  • write sends a message to another user on the system by copying lines from the sender's terminal to the recipient's terminal.
  • wall sends a message to the terminal of each user currently logged into the system.
  • history shows a numbered list of commands you executed in this and the previous session. If there are quite a lot of them in the history list, you will see the latest ones.
  • jobs displays a list of all running and suspended tasks.
  • kill end the process (you must specify which one).
  • killall will allow you to manage processes using their names or file names, and not identifiers as in kill. All specified processes are terminated.
  • kernelversion shows the main and additional version kernels.
  • nice Allows you to display or configure the priority of a task.
  • ps displays a list of all running processes.
  • pstree shows the hierarchy of system processes, which clearly shows their interdependence.
  • renice sets the priority for the specified task.
  • script allows you to write all output from the terminal to a file. To stop recording, press Ctrl+d. If the file name is not specified, it is written to typescript.
  • times shows full time execution of processes for the entire system and a given user.
  • top launches a program that allows you to manage processes. And a lot of additional, useful information.
  • CD change current directory. Defaults to home directory current user(if without parameters).
  • dir displays files in the current directory in alphabetical order and case sensitive.
  • file shows the content type of the specified file (text, executable, data).
  • find search for files in the current directory. If you specify a path, you can search everywhere.
  • free displays information about random access memory, swap, cache, free memory, shared, etc.
  • ls shows all files in the current directory in alphabetical order. Similar to dir.
  • last shows a list of users who have logged in since the /var/log/wtmp file was created.
  • lastlog checks the login history of registered users. Formats and prints the /var/log/lastlog file.
  • logger sends a request to the syslogd daemon asking it to write a message to the system log.
  • lpr sends the document to the print daemon for printing.
  • chmod changes the file access mode. Character or numeric format.
  • chown change the owner of the specified file. Root access is required.
  • chage used to change the validity period of an account. For administration.
  • chfn changes user information in the /etc/passwd file from which the finger command takes information.
  • chgrp command for an administrator to change the owner group of a file.
  • clear clears the terminal screen (if possible).
  • crontab provides the ability to perform certain tasks on a schedule. It is most often used by the administrator, although users may also have their own tasks.
  • csplit splits the file into several parts. You must specify the splitting method (lines, etc.).
  • cp copies one file to another, or several files to a directory.
  • dd copying a file while simultaneously performing various additional transformations.
  • dc calculator.
  • debugfs used to restore the file system (ext2,ext3) if the fsck command is not enough.
  • df shows the amount of used and free disk space for all mounted file system partitions.
  • du shows the number of disk blocks occupied by each directory file.
  • mc starts the program Midnight Commander file manager in a text console. It resembles MSDOS managers and is quite simple and easy to use. There are a lot of necessary and convenient functions.
  • mkdir creating the specified directory.
  • man reference guide.
  • mcat copies the raw data to a floppy disk.
  • mcopy uses a formatted MSDOS floppy disk to copy files to and from Linux without pre-connection floppy disks to the file system.
  • mdel deletes a file on a formatted MSDOS floppy disk.
  • mdir displays the contents of a directory on an MSDOS floppy disk.
  • mdu shows the disk space occupied by the MSDOS directory.
  • mesg controls access to your terminal so that colleagues cannot bombard you with messages using the write command
  • mformat creates the MSDOS file system on a floppy disk.
  • mkbootdisk used in some distributions to create boot floppy, containing everything needed for an emergency boot.
  • mktemp creates unique name file for temporary work.
  • mlabel creates a volume label on MSDOS on a formatted floppy disk.
  • mmd creates a MSDOS subdirectory on a formatted floppy disk.
  • mmount connects a formatted MSDOS device to the file system.
  • mmove Moves or renames a file on an MSDOS floppy disk.
  • more A tool for page-by-page viewing of a text file.
  • mv renames or moves files or directories.
  • rm deleting the specified file. You can delete a lot.
  • rmdir deleting the specified empty directory.
  • safedelete deleting the specified file to the safedelete directory, where it is stored for some time before being permanently deleted.
  • stat display of all available information about the specified file.
  • touch changes the time the file was last accessed or modified to the current time.
  • undelete recovers files deleted by the team safedelete.
  • wc shows the number of lines, words and characters in the file.
  • bunzip2 unpacks the specified file 30% faster than gzip.
  • bzip2 compresses the specified file using an accelerated algorithm.
  • bzip2recover makes an attempt to recover data from a damaged bzip2 compressed file.
  • compress compresses the specified file using a different algorithm.
  • uncompress unpacks the file compressed by the previous command.
  • cpio allows you to create archives and extract files from archives. Allows you to copy files. The appropriate parameters must be specified.
  • gpg allows you to encrypt and decrypt a file. Encryption method public key. Allows you to create electronic signatures. If you do not have this program, download http://www.gnupg.org
  • gzip compresses the specified file.
  • gunzip unpacks the specified file (extensions .Z, .gz, .tgz, .zip).
  • gzexe allows you to compress executable file With specified name so that it is automatically decompressed and executed when the user issues a command to execute the compressed file.
  • gpasswd sets the group password.
  • mcrypt Encrypts the specified file. Created new file in the working directory with the extension .enc. You will be prompted to enter your password. Don't forget it.
  • mdecrypt decrypts the same file. If these utilities are not available, download http://mcrypt/hellug.grl
  • tar places two or more files into a new or existing archive or extracts them from an archive. When given a directory, archives all files in the directory and subdirectory.
  • talk allows you to conduct an interactive dialogue with an INTERNET user.
  • tee sends output data to two output devices. Can be simultaneously output to the screen and to a file.
  • toe provides information about existing terminals that can be used for further work.
  • touch changes the file creation time to the current one. If the file does not exist, it creates a new, empty file.
  • unarj unpacks or lists the contents of the specified archive in .ARJ format (MS DOS compression format).
  • unzip unpacks and extracts files from archives created by ZIP utilities(Linux,MS DOS,Microsoft Windows).
  • zip archives and compresses files.
  • zipinfo displays information about the contents of the archive. If you specify a name, it will display information about a specific file.
  • zipnote allows you to display and edit comments on files from a ZIP archive.
  • zipsplit allows you to divide zip archive into small enough pieces to write them on removable media, and writes files to the specified device (floppy disks).
  • zforce adds the .gz extension to all files in the working directory, or to a specified file, that have been compressed but do not have an extension. prevents re-compression.
  • uuencode encodes binary file for transmission over ASC11 networks.
  • uudecode decodes the above named file.
  • autorun automatically recognizes all available CDROM drives on the system, mounts them when a disc is inserted, and can run individual applications(for example a player). To use, you need to add parameters to the drive file.
  • badblocks check the specified device for bad sectors (specify device).
  • eject removes media from the specified device. If the device is mounted, the command unmounts it before removing the media.
  • e2fsck checks and, if necessary, restores the damaged file system volume (ext2,ext3).
  • echo Prints a line of text to the standard output device.
  • fdformat formatting a floppy disk. Additionally, enter the device name and required type formatting.
  • fg switches a process running in the background to foreground mode.
  • fgconsole shows the number of active virtual consoles.
  • fsck checks and restores the file system.
  • mount mounting the file system.
  • umount unmounting the file system (in both commands you must specify what exactly).
  • rdev when called without parameters, displays information about the current file system.
  • rcp used to copy files from one computer to another.
  • rdate receives the date and time value from another node on the network. Used to synchronize the system time of nodes.
  • rename renames files. Very convenient when there are a lot of files.
  • resize resizes the virtual terminal window in a graphical environment.
  • restore Recovers files archived using the dump command.
  • runlevel displays the current and previous run levels.
  • shred performs safe deletion file by first overwriting its contents on another disk.
  • sleep pauses the start of a process for a specified number of seconds.
  • usleep pauses for microseconds.
  • sync Clears file system buffers.
  • cmp produces quick comparison two specified files. If they are identical, then no messages are displayed.
  • column formats the input text from the specified file into a five-column list.
  • diff compares two specified text files. Each difference is displayed in context. Allows you to compare directories.
  • diff3 compares three specified files and displays the results.
  • enscript converts the specified text file to Post Script format. The output can be printed or written to a file.
  • fmt this utility formats each line in the specified file so that all lines have the same width.
  • head The utility displays the first ten lines of a file. Several files are also possible.
  • ispell launching an interactive utility to check spelling in the specified file.
  • id displays effective values user and group IDs for the current user.
  • ifconfig displays the status of the current network configuration or configures the network interface.
  • less displays the contents of the specified file on the screen and allows you to view it conveniently.
  • nl The command numbers the lines in the specified file.
  • paste combines corresponding lines of files into columns. If desired, you can combine several files.
  • pdf2ps converts the file PDF format in Post Script. The result is written to disk.
  • pdftotext converts a file from PDF format to text and writes the result to disk.
  • pr prepares text for printing by formatting it into pages. You can prepare multiple files.
  • sort The command allows you to sort the lines of a file in alphabetical order.
  • split splits the file into parts.
  • zcat;zmore displays the contents of a gzip compressed file on the screen without decompressing it.
  • zcmp
  • zdiff compares gzip compressed two files without decompressing.
  • zegrep;zfgrep;zgrep search for a specified string or expression in a gzip compressed file, without unpacking.
  • aumix runs interactively a utility that controls various settings sound card.
  • cdda2wav The utility is designed to record audio tracks from an audio CD into WAV format files. If the file name is not specified, then the recording goes to the audio.wav file in the current directory.
  • cdlabelgen The command is designed to prepare covers for CD boxes. The result is in a Post Script file format. A Perl language interpreter of at least version 5.003 is required.
  • cdp launch the audio CD player in text mode.
  • cdparanoia reads audio tracks from audio compacts and records in WAV, AIFF, RAW files.
  • combine combines two or more graphic files into one. A huge number of special effects. It is part of the Image Magick package and can be taken from http://www.imagemagick.org
  • convert converts the specified input graphic file, on weekends. Recognizes many formats. Download in the same way as the previous one.
  • identify determines the format and characteristics of a graphic file and checks for integrity and errors.
  • mogrify converts a graphic file and overwrites the original one.
  • montage converting multiple files into a combined image. Download http://www.imagemagick.org
  • mpg123 plays an MP3 audio file on the main playback device. Enter the file name or its Internet address. To stop playback Ctrl+c. To stop and exit the program, press Ctrl+c twice.
  • play reproduces sound file with the specified name. Automatically recognizes the file type. Allows you to add different sound effects to the files being played.
  • playmidi plays sound files in MIDI format.
  • rec Records input from microphone or other inputs into an audio file. The file type should be specified using the (type) parameter. It is possible to add sound effects.
  • sox converts samples from format input signal, for the weekend with added effects.
  • emacs launching the Emacs text editor.
  • joe An easy-to-use editor that works in text mode.
  • pico simple and easy-to-use text editor. Convenient for editing configuration and simple files.
  • vi launching the classic text editor VI for UNIX systems.
  • dmesg displays kernel messages, including those displayed at startup and afterwards. To make it easier to read, enter dmesg|less.
  • groupadd creating a user group with the specified name.
  • groupdel deletes the group with the specified name.
  • groupmod changes the settings of the group with the specified name.
  • mkpasswd creates a high-quality password that is nine characters by default and contains at least mixed-case letters and numbers.
  • passwd allows the user with the specified name to change their password account. root can change any user's password.
  • pwgen creates a high-quality password that is easy to remember. The password length is indicated by a number. If this utility is not available, download http://metalab.unc.edu/pub/Linux/system/security
  • quota Shows current disk usage statistics and current limits for the user or group with the specified name.
  • quotacheck examines the file system for disk space usage.
  • quotaon Enables or disables disk space usage restrictions.
  • rpm launches the package manager, a utility that allows you to install, check and update packages with the rpm extension.
  • rpmfind search for the required package in the RPM package database via the INTERNET. Latest version of the utility http://www.rpm.org
  • tmpwatch deletes all files in the specified directory if they have not been accessed within the last n hours. Clears temporary directories.
  • useradd creating a new user with the specified name.
  • userdel deletes the user with the specified name.
  • usermod changes the settings of the user with the specified name.
  • fetchmail mail receiving utility. Works in the background. Downloads mail from the specified server. If it is not there, you can download it from http://www.freshmeat.net
  • ftp establishes a connection to the specified node and allows you to download or upload files.
  • lynx launching a console WEB browser.
  • mail utility for editing and viewing e-mail. Sending and receiving letters.
  • netstat Displays information about the network subsystem. There are a lot of settings and parameters.
  • ping sending to specified address packets to check the possibility of connecting to this node.
  • telnet opens a terminal window on the remote host and starts an interactive session.
  • wvdial the program connects to the INTERNET via PPP protocol using the settings stored in the /etc/wvdial.conf file
  • wvdialconf searches for a modem, determines the port to which it is connected, its initialization string and the maximum data transfer rate. This information is automatically written to a file (see above). Root access is required.
  • ar archiving tool designed to create and unpack an archive.
  • arch displays information about the CPU architecture.
  • at Queues jobs for later execution at a specified time.
  • atq shows a list of tasks that are queued for execution.

Teams Linux consoles, or as they also say command line, this is a kind of intermediate link between the user and the computer itself. In order for the machine to carry out your order, it must be given the appropriate command. Initially, this is exactly how the relationship between a person and a computer happened, but a little later, it appeared additional tool a mouse that greatly simplified the entire process of information exchange and made it more accessible to all users. However, the console today remains powerful and sometimes very convenient tool to perform all kinds of actions.

At all, console utilities There are a great many, but here we will briefly, as an example, consider only two of them, but they are very important and often used. Utility Apt-get, designed to work with software packages. For those who do not recognize the console at all, they can use the wonderful graphical shell for Apt-get, entitled Synaptic(available in the official repository).

How to use the utility?

//basic formula

sudo apt-get command

//as an example, update all packages

sudo apt-get upgrade

Basic apt-get commands when working with packages.

apt-get update //update info. about packages from repositories
apt-get upgrade //update all packages
apt-get dist-upgrade //updating the system as a whole
apt-get clean //cleans the lock. storage other than cache files
apt-get autoclean //same as clean, with deleted cache files
apt-get check //updates cache and check. unsatisfactory dependencies
apt-get autoremove //removing previously downloaded but unnecessary packages
apt-get remove //removing the package from the save. config. files
apt-get purge //removing the package with all dependencies
apt-get install //install the package
apt-get build-dep //install everything to build source packages
apt-get source //downloads source packages

Options:

-h, --help //reference
-q, --quiet //hide the progress bar
-qq //do not show anything except errors
-d, --download-only //just receive packets and exit
-s, --simulate //perform event simulation
-y, --yes //automatic answer "Yes" to all questions
--reinstall //reinstall packages
-f, --fix-broken //fix broken dependencies
-m, --ignore-missing //ignore missing packages
-u, --show-upgraded //show updated packages
--no-upgrade //do not update packages
-b, --compile, --build //assemble the package after receiving
-D //when deleting, remove dependent components
-V //show package version numbers in detail
--no-remove //if the packages are marked to deleted., then apt-get off
--force-yes //force execution of the specified operation

Funny.

apt-get moo

You should see a cow asking, “Did you moo today?”

"aptitude" utility.

Let's consider another very good utility entitled " aptitude", in fact, this is the same as " apt-get", but is considered better, and also has a pseudo- GUI. The principle of operation is exactly the same, only instead of " apt-get", you need to enter a value " aptitude". First, let's install the utility itself:

sudo apt-get aptitude

Now if you type: aptitude, you will be taken to the program interface.

Let's look at some commands:

// Install the package.

sudo aptitude package1 package2 package3

As you can see, you can install it right away unlimited amount packages at the same time. No matter how many times you install them, aptitude will automatically resolve all dependencies, all you have to do is agree (y) and press (enter). Also, by analogy, you can remove packages:

sudo aptitude remove package_name1
or
sudo aptitude purge package_name1

The first command deletes only the package files without touching the settings, the second deletes everything completely. You can view the package description like this:

aptitude show package_name

In general, this utility is an absolute analogue of " apt-get", but when installing and removing packages, it is advisable to use it rather than " apt-get". At least on the official website Ubuntu give exactly the same recommendations.

Other console commands.

List of commands related to information.

hostname //machine network name
whoami //current user name
uname -m //shows the machine architecture
uname -r //kernel version
sudo dmidecode -q //inform. about the device. ensuring the system
cat /proc/cpuinfo //information about the processor
cat /proc/interrupts //interrupts
cat /proc/meminfo //all memory information
cat /proc/swaps //all information about swap
cat /proc/version //kernel version and other information
cat /proc/net/dev //network interfaces and statistics
cat /proc/mounts //mounted devices
cat /proc/partitions //available sections
cat /proc/modules //loaded kernel modules
lspci-tv //PCI devices
lsusb -tv //USB devices
date //The current date
cal //calendar and current month
Cal 2012 //shows the entire year 201

Commands related to reboot and shutdown processes.

shutdown -h now //turn off the system
init 0 //turn off the system
telinit 0 //turn off the system
shutdown -h hours:minutes & //schedule system shutdown
shutdown -c //cancel scheduled shutdown
shutdown -r now //reboot the system
reboot //reboot the system
logout //end session

File operations and more...

cd /home //go to home directory
cd.. //go to higher level
cd ../.. //go up 2 levels
cd- //go to previous directory
pwd //show the path to the current directory
ls
ls -F //show files and directories
ls -l //show. details about files, directories
ls -a //show hidden files
mkdir dir1 //create a directory named dir1
mkdir dir1 dir2 //create directories dir1 And dir2
mkdir -p /tmp/dir1/dir2 //create a directory in the specified location
rm -f file1 //delete file with name file1
rmdir dir1 //delete directory with name dir1
rm -rf dir1 //delete directory dir1 and all its contents
rm -rf dir1 dir2 //delete directories dir1\dir2 and contents
mv dir1 new_dir //rename / move directory
cp //copy files/folders
ln -s //create a symbolic link
chmod //assigning rights to files

Search files and directories.

Forgot where you saved it? No problem! You can find everything in the console.

find / -name file1 //search for files, director. beginning With /
find / -user user1 //search for files, direct. Withuser1
find /home/user1 -name \*.bin //search for files .bin V / home/ user1
find /usr/bin -type f -atime +100 //claim bin. files, sudden 100 days
find /usr/bin -type f -mtime -10 //claim files created/edited in 10 days
find / -name \*.deb -exec chmod 755 "()" \; //claim files ( .deb) and change. rights
locate\*.ps //find files with extension.ps
whereis halt //show the path to the programhalt
which halt //show. full path to programhalt

At first glance, all this may look somewhat intimidating, but this is only at first glance. Don’t immediately rush into panic and immediately return to Windows(y). Modern distributions, as well Ubuntu in particular, it completely allows you to do without the command line. However, the command line, in some cases, is much more convenient than the graphical interface. Also, it is not at all necessary to memorize all these commands; it will be enough to create a text file, copy all the contents into it and keep it nearby, like a cheat sheet that you can use if necessary.

Of course, this is not all that concerns the topic of the command line and the commands themselves; if anyone is really interested in this, I can advise you to go to following link, you can find and download a lot of things there, the only question is whether you need it all. I generally doubt that today there is at least one person in the whole world who would know by heart all the existing console commands (maybe I’m wrong).

Linux command references: http://books.tr200.ru/v.php?id=278389

The need to work in a text console is the very cliff on which the good intentions of users who want to quickly master Linux are most often dashed. And, as a rule, even before they even try to install the system. The myth that the command line is unfriendly is so firmly rooted in the public consciousness that it is not easy to destroy it.

However, this is really nothing more than a myth that can be invented about anything. At least about a regular computer keyboard. Anyone who sees it for the first time in their life will be quite surprised that the buttons are not arranged alphabetically. And this decision will probably seem very strange to him, since at first he has to search for each letter for quite a long time.

However, it never occurs to anyone to place the keys in any other way. Because the convenience of this seemingly unfriendly interface has long been proven and is beyond doubt. And if you master typing blindly, the time spent on learning will pay off many times over.

As with the keyboard, aversion to the command line is most often not technical, but psychological. Working in the console is not a forced measure caused by the lack of “normal” tools, and not the bravado of “advanced” users, but the fastest and user-friendly interface to solve a number of problems.

What are its advantages? First of all - in versatility. No matter what distribution you use, the basic commands will be the same. We must not forget that text mode is more stable than graphic mode. Just remember the famous BSoD (“blue screen of death”) in Windows. For some reason, the inscription is displayed in the console, and not in a beautifully drawn window.

Since the Linux graphical interface is essentially a regular application program, its failure does not lead to a general system crash. If the user is not afraid text mode, then he will quickly contribute necessary changes to the appropriate configuration file and restart the system. Otherwise, you will have to resort to completely reinstalling it, which will take much longer.

Finally, console commands are useful for some routine operations. After all, the computer was invented to automate the work process. Of course, in order for the console to work effectively, the user will have to spend a little time learning standard Linux commands. But it is compensated quite quickly.

There are two ways to switch to command line mode. The first is to activate the text console. To do this, press the key combination Ctrl+Alt+F[console number]. An invitation to register in the system will appear, where you need to sequentially enter your login and password. The second way is to open the console directly in the window manager. In this case, the user continues to work in graphical mode. It is important to understand that in both the first and second cases, all running programs will continue to function normally.

If everything is clear with launching the terminal in graphical mode, then activating additional consoles may raise a number of questions. What specific function key should I press? How many consoles can function simultaneously and is it possible to change their number? How to go back to the GUI

Typically, there are six text consoles available by default. Since maintaining each requires approximately 4 MB of memory, it is advisable to reduce their number on weak machines. To do this, open the /etc/inittab file with system administrator rights, find a section consisting of entries like “2:2345:respawn:/sbin/mingetty tty2”, each of which corresponds to one console, and put a comment sign (#) opposite extra. The number of lines in this section is equal to the number of text consoles. Moreover, in most distributions, one of them is used not for user registration, but for system messages. Isn’t it very convenient in case of any problems: the medical history is always available.

The number of virtual consoles is set in the /etc/inittab file

The first digit in the line is the console number and, accordingly, the number function key, which must be used in combination to call it. To switch text consoles, you need to press not Ctrl+Alt+F[console number], but simply Alt+F[console number] - the Ctrl key is used only in graphical mode.

To return to the graphical interface, you must activate the corresponding console. Her number is one Furthermore, which was last registered in /etc/inittab. For example, if six text consoles are used, then window manager launched on the seventh.

When working in text mode, the visual marker for the start of a line can be of two types: a sharp sign (#) and a dollar sign ($). The first indicates that the user is running as root and all system files are open to him. In this case, it is necessary to exercise special caution - rash actions are fraught with serious consequences.

A regular user is represented by a dollar sign. There is also a small nuance here. The concept of restricting access rights means that some commands that require extended privileges will refuse to run. Moreover, the specifics of UNIX are such that no hints or explanations will appear on the screen - it is assumed that a person is in complete control of the system and does not at all need the help of programs, from which only the unquestioning execution of the owner’s orders is required.

On the other hand, those looking for additional information will always find it. One of the most important and frequently used commands is man [name]. It will display a help manual for any system object whose name is specified as an argument. Of course, information is not taken out of thin air, but from a file, for which it must be physically present on the disk. Please note that some developers try to reduce the size of the distribution by not including help pages. In this case, they must be installed separately.

The man command will display a reference manual for any system object.

Since man is a system object just like everyone else, you can get help on it by typing man man. Apparently, the user who downloaded Linux for the first time should start with it.

Each guide is made up of sections called fields. The NAME field is intended for brief information about the object. The SYNOPSIS field contains information about how to run the program. Finally, the DESCRIPTION field is a detailed description.

But what should the user do if he does not yet know which program can complete his task? Use the apropos or whatis commands. They are intended for searching information in manuals. The difference between them is that the first searches the entire database, while the second searches only by the names of objects contained in the NAME field. Obviously, one is slower but provides more information than the other.

Most often, operations to configure the system are performed in text mode. Does this mean for the user that he will have to activate the new console using the combination Ctrl+Alt+F[console number]? Not at all: in most cases it is not necessary to leave the graphics mode.

In order to run any program with administrator rights, you need to open a terminal and type the su command without parameters, then the system will ask you to enter the root user password - and you will have full access to the files.

Now let's look at a few examples that indicate that the command line was not invented to mock the user, but, on the contrary, for his convenience. Let's perform a number of fairly popular operations without the help of “menus and buttons”.

Let's say you need to split a file into several parts in order to send it by email ( original size so big that the server won't let it through). To do this you need to use the split command. It copies the file, breaking it into separate fragments of a given size (default - 1 MB). Two names should be used as arguments: the source object and the prefix of the output.

For example, there is a large video called name.avi. We need to split it into 10 MB pieces. The command will look like this: split -b1000k name.avi name. The first argument specifies the volume of the resulting object, the second is the name of the source, and the third is the prefix of the result name. Thus, as a result of the operation, the files name.aa, name.ab, name.ac, etc. will be obtained. The command cat name.* > name.avi will help to put the pieces together.

With help cat commands you can quickly view the contents of the file

Often the user needs to compare two files. The easiest way is to use the command cmp [first file name] [second file name]. If the objects completely match, then the program will silently exit, because there is nothing to tell it. If it detects any difference, it will give the user the number of the corresponding line.

If a complete list of inconsistencies is required, then you should use the diff command [name of the first file] [name of the second file]. In this case, the program will display a complete report.

In some cases, it is convenient that information about differences does not appear on the screen, but is immediately saved in a file. To do this, you can use the output redirection function, and the command will look like this: diff [first file name] [second file name] > [report file name].

The output redirection operation allows you to use commands that seem quite simple at first glance to significantly speed up your current work - for example, compiling a complete list of all files in a directory.

The ls program is responsible for viewing the contents of the directory. In order for the result of its work to be saved in a file, you need to use the feature already known to us and type ls [directory name] > [name of the file where the information will be written] in the console.

The contents of the directory can be viewed by typing the ls command in the console

Finally, one last note. Users often complain that working on the command line is associated with increased memory load. Like, you have to keep all the names of utility utilities in your head. This is not entirely true - in most cases it is enough to know only the first few characters. On click Tab keys the shell itself will try to add the full name (or offer options, if any). ka

The Linux operating system is very popular among programmers and those who like to tinker, because it provides active use console containing hundreds of commands. If you decide to seriously take up learning this flexible OS, you should first learn basic commands.

Why do they exist in Linuxconsole commands? By entering them into the console, the user can quickly perform a lot of actions: opening, moving and copying files, viewing various information and statistics, monitoring and debugging, obtaining detailed information about the system, modification of the software and visual part of the system. And these are just some of the features you get with these commands.

Many have additional parameters, and some do not work at all without them. To begin with, try simply entering commands into the console and studying their effect.

The ability to modify the system with commands makes Linux a very versatile operating system. You can customize it for yourself by changing anything in it. At first, the commands may seem complicated, but once you learn them well, you will significantly speed up your work with the computer and begin to truly enjoy it, realizing that everything in it is customized by you to suit your needs.

Remember that for full-fledged work with the console you need administrator rights. Below is a list of the main commands in the Linux console and their explanation.

1. Simple steps

ls— display a list of files in the current directory.

CD[directory] - change the current directory. If a directory name is not specified, the user's home directory becomes the current directory.

cp<что_копировать> <куда_копировать>- copy files.

mv<что_перемещать> <куда_перемещать>— move or rename the file.

rm<файлы>— delete files.

mkdir<каталог>— create a new directory.

rmdir<каталог>— delete an empty directory.

rm -r<файлы и/или каталоги>(recursive delete) - delete files or directories and their subdirectories. BE CAREFUL with this command because Linux doesn't have a system yet full recovery deleted files(if you don't use special programs to place deleted files in a special directory, something like the “recycle bin” in Windows).

cat<имя_файла>- output the contents of the file to standard output(default - to screen).
You can record text you type on the screen using next sequence actions:

cat ><имя_файла>
.
.
.
CTRL/d

more<имя_файла>— viewing the contents of a long text file page by page.

less<имя_файла>— viewing the contents of a text file with the ability to return to previous pages. Press q when you want to exit the program. "less" - analog DOS commands“more”, although very often “less” is more convenient than “more”.

pico<имя_файла>— edit a text file using the pico text editor.

tar -zxvf<файл>— unpack the archive tgz or tar.gz

find<каталог>- name filename - find a file with the name “filename” and display the search result on the screen. The search starts with the catalog<каталог>; "filename" may contain a search mask.

pine is a good text-oriented email reader.

mc- launch the file management program “Midnight Commander” (Looks like “Norton Commander”, but its capabilities are closer to far).

./ Program_Name - run an executable file in the current directory if the current directory is not in the list of directories specified in the PATH environment variable.

xterm(in X terminal) - launch a simple terminal in graphical shell X-windows. To exit it, type "exit".

2. Standard commands and commands that provide information on the command system (always typed on one line)

pwd— display the name of the current directory.

whoami— display the name under which you are registered.

date— display date and time.

time<имя программы>— execute the program and obtain information about the time required for its execution. Don't confuse this command with date. For example: I can run the ls command and find out how long it takes to list the files in a directory by typing the sequence: time ls

who— determine which user is working on the machine.

rwho-a— identification of all users connected to your network. This command requires that the rwho process be running.

rupture— which machines are running on the network and which are stopped.

finger<имя_пользователя>— system information about the registered user. Try: finger<ваш login-name>

uptime— the amount of time that has passed since the last reboot of the operating system.

ps a— display a list of current processes in your session.

top— an interactive list of current processes, sorted by CPU usage.

uname -a— display information about the operating system version.

free— display information on memory usage.

df -h— display information about free and used disk space.

du. -bh | more— display information about the size of files and directories, starting from the current directory.

set|more— display the current values ​​of environment variables. (Not for all shells. For csh/tcsh - printenv | more, although set will also show useful information.)

echo $PATH— display the value of the environment variable “PATH” The echo command can be used to display the values ​​of any environment variables. Use the set or printenv commands to get a complete list.

3. Networking

ssh- ensures safe entry into remote session work with another machine, and also allows you to perform given command on a remote machine without logging into a work session:

ssh[-l Your_user_name_on_the_remote_machine]<имя_удаленной_машины>— entering a session on a remote machine. Use the machine name or its IP address. (You must be logged in to this remote machine). If your username is the same on the local and remote machines, then you don’t have to type it, i.e.: ssh<имя_удаленной_машины>- will allow you to log into a session on a remote machine

ssh<Ваше_имя_пользователя_на удаленной машине@><имя_удаленной_машины> <команда>— will execute the specified command on the remote computer and send you the result of its execution on the screen (When establishing a connection via ssh, you will have to enter the password that you have on the remote computer; in this case, the password will be transmitted over the network in encrypted form, i.e. secure way.)

scp- provides secure copying files on the network:

scp<имя_файла_на_локальном_компьютере> <Ваше_имя_пользователя_на удаленной машине>@<имя_удаленной_машины>: - copies the file from local computer to your root directory on the remote computer (the presence of “:” at the end of the command is required).

telnet<имя_удаленной_машины>— contact another machine via telnet. Log in to your session once the connection is established using your password.

ftp<имя_удаленной_машины>— contact via ftp with remote computer. This type of connection is good for copying files from/to a remote machine.

It is preferable not to use telnet commands and ftp, and use only ssh and scp, as they ensure the security of the network connection!

hostname -i— shows the IP address of the computer you are working on.

4. Some administration commands

alias ls="ls -Fskb --color"— create an alias alias so that one command can launch more than one complex combination commands Place the alias creation in the /etc/bashrc file if you want these aliases to be available to all users on your system.

For tcsh, the format for defining alias is different:

alias la ‘ls -AF —color=none’

kapasswd— command to change the password for accessing the AFS file system. When working on a basic LIT Linux cluster, you should use only this command (and not the passwd command!) to change the password for joining the cluster.

passwd— change your password on any local computer.

chmod<права доступа> <файл>— change access rights to a file that you are the owner of.
There are three ways to access the file:
reading - read (r), writing - write (w), execution - execute (x) and three types of users:
the owner of the file is owner (u), members of the same group as the owner of the file (g) and everyone else (o).
You can check your current access rights in the following way:

ls -l file name

If the file is accessible by all means to all users, then next to the file name there will be the following combination of letters: rwxrwxrwx
The first three letters are the access rights for the file owner, the second triplet are the access rights for his group, the next three are the access rights for the rest. Lack of access rights is shown as “-”.; For example: This command will allow you to set read permissions for the file "junk" to everyone (all=user+group+others):

chmod a+r junk

This command will remove the permission to execute the file from everyone except the user and group:

chmod o-x junk

For getting additional information type chmod --help or man chmod or read any Linux manual. You can set default permissions for files you create using the "umask" command (type man umask).

chown<новый_владелец> <файлы>— change the owner of files.

chgrp<новая_группа> <файлы>— change the group for the file.

You can use the last two commands after you have made a copy of the file for someone else.

5. Process control

p.s. | grep<Ваше_имя_пользователя>- display all processes running on the system under your user name.

kill- “kill” the process. First, determine the PID of your “killed” process using ps.

killall<имя_программы>- “kill” all processes by program name.

xkill(in the X window terminal) - “kill” the process whose window you point to with the cursor.

6. Linux built-in software utilities and languages

emacs(in X terminal) - emacs editor. Very multifunctional, but very complicated for inexperienced users.

gcc - GNU C compiler. There are a lot of good guides by use.

g++ — GNU C++ compiler.