Unix commands: list, features of use, frequency of use

Table of contents:

Unix commands: list, features of use, frequency of use
Unix commands: list, features of use, frequency of use

UNIX operating systems are widely used on modern servers of various processor architectures, workstations, network and mobile devices. The term "UNIX command" refers to a family of multi-user operating systems. The graphical interfaces of the OS are varied. But for Mac or Linux users who want to get the most out of their operating system, getting to know the Unix command line is a must.

History of UNIX

History of UNIX
History of UNIX

The first version of UNIX was developed in 1969 by Ken Thompson at Bell Laboratories using an idle PDP-7, soon joined by Dennis Ritchie.

UNIX was originally intended to be used inside the Bell System for programmers. Thompson and Ritchie worked for many years to develop various versions of UNIX. Ritchie developed the C language to support UNIX. The third version involved rewriting the OS in C. As UNIX advanced, it became widely used at AT&T, and because the source code was available, it was gradually adopted.other organizations in the field of computer science. One of the most important achievements made in UNIX by the Berkeley programmers was the provision of support for the Internet Network Protocols (TCP/IP).

In 1988, BSD, AT&T UNIX, and other operating systems were merged into UNIX System V.4. This new generation of OS combines the best features of its predecessors to become the standard and foundation for AT&T UNIX, SUNOS Sun Microsystems, IBM AIX, and HP-UX HP.

OS Benefits:

  1. UNIX provides multi-user, multi-tasking, secure RAM using minimal memory.
  2. Provides strong user protection through account verification and authentication.
  3. Simplifies I/O operations.
  4. Very portable, which means it can run on several different hardware platforms, making it easy for users to install on whatever hardware they prefer to use.

Main operating system components

The main components of the operating system
The main components of the operating system

The main components of the UNIX OS are simple and not numerous, the interaction of these components with each other is unique. The three main components of the UNX system:

  • Kernel (KERNEL).
  • Shell (SHELL).
  • File system.

The UNIX kernel manages the physical RESO urces of the hardware computer, devices, memory, handles d (daemons). Manages functions between system programs and hardware and executes all basic UNIX commands.

The core managesthe following elements:

  1. File system and structures.
  2. Device management, such as storing data on disk.
  3. Process management, eg daemons.
  4. Memory management, such as swap space.

The shell is the interface between the user and the kernel. It acts as a command interpreter. It takes basic UNIX commands issued by the user, interprets them, and then sends the executable to the kernel. The three most common shells are Bourne, C and Korn. There are also popular open source shells such as Z and bash, both extensions of Bourne.

To identify the one used in UNIX, execute, for example, for zsh, the UNIX echo command:

  • echo $SHELL;
  • /bin/zsh.

A file system is a hierarchy of directories, subdirectories, and files that are organized or grouped for specific purposes, all under a system call interface. The hardware provides the file system, process control subsystem, memory management, and OS over system calls. Programmers use kernel calls to deploy useful functions, to compile and manipulate examples.

Development environment

Development environment
Development environment

The UNIX programmer interface is defined by calls. Most UNIX system programs are written in C, and all calls are C functions. Because the call details are known only to the compiler, this makes portability a top feature. UNIX programs. System calls for manipulating files are, for example: creat, open, read, write, close, link, unlink, and trunc.

A new process is created by calling fork. The process is a copy of the process space of the parent process calling fork.

Signals are used for exception handling. UNIX has 20 different signals. For example, an interrupt signal is used to interrupt a command before completion of execution, normally performed by the user.

Disadvantages of the command line:

  1. Some tasks are difficult or impossible to do on the command line.
  2. Tasks that require a lot of typing, such as long filenames, can be annoying and tiring due to the lack of minimal cut support.
  3. For most people, learning and remembering typed commands is difficult unless they use the commands all the time.

Function benefits:

  1. In almost all cases, it is much faster and easier to use for experts than for beginners.
  2. It can be used remotely with more ease than a GUI.
  3. Remote GUI is SLUGGISH.
  4. When absolute precision is needed, the mouse/GUI is too inaccurate.
  5. For complex tasks, the command line can be scripted to automate processes.

User interface

User interface
User interface

Developers and UNIX users can use programs that are already compiled and available for execution. Theseprograms can be divided into functions, such as directory and file handling: mkdir, ls, touch, file, rm, link, unlink, cat UNIX command, file sorter sort, file comparison diff, pattern search grep and awk. In addition, text editors such as vi, vim, sed, and others are available. These commands are executed by the user's interpreter or shell.

Standard I/O refers to the three types of files a process can open. They are known as standard input (file descriptor 0), standard output (1), and standard error (2). A program can read from standard input and send the output to the user's screen or to a file with standard output.

The user can send standard output to a file named test1 or send test1 files as input to the program:

There are three main categories of I/O in UNIX:

  • blocking devices;
  • character devices;
  • sockets for network communication.

Block devices, this category includes disks and tape. The block device goes a long way in isolating disk details from the rest of the kernel. Block devices are available through a system file. Example: /dev/sda the first scsi drive on the first scsi bus, the first scsi drive on the first scsi bus.

Character devices, this category includes printers, terminals. Example UNIX terminal identification command: /dev/null abit bucket or bottomless sink for data.

To display the block and character devices on the system, execute the following command in a shell. The truncated output shows some /dev devices on the UNIX server.

Device on UNIX server
Device on UNIX server

Traditional OS commands

Traditional OS Commands
Traditional OS Commands

No matter what shell the user is using, whenever a command is entered, the user will start the UNIX program. A simple example to count the number of files in the /etc directory: IDG.

This sequence of commands illustrates two important concepts:

  • ls UNIX equivalent to dir on Windows, lists the contents of a directory;
  • word count wc.

In UNIX, parameters are traditionally prefixed with a single dash "-". These command line options change the behavior of the program. Often they override the defaults set in the environment. If you want to change the way the command is run on a permanent basis, automatically set the environment variable at login. Many commands allow you to combine options on the same line, such as ls -la, but others do not. You can learn about all command options by checking its manual or man pages.

Learning and using string parameters is a big part of UNIX efficiency. Some commands have many options, but usually only a few options are enough to perform a given task, and most options are used only when writing programs in a shell language.

There ismany commands related to the file system, since it is the main one for the OS.

The ls command is the most commonly used and has many options to customize the output. Dot files (files or directories) whose names begin with a dot or period are hidden by default. These files or directories usually contain configuration information or logs for UNIX. For example, the.bash_history file records all commands that are entered on a line.

Another command you'll need right away is cd, which is used to change directories. It is similar to the one in Windows, but with a significant difference. In UNIX, all drives appear as a single drive. If on Windows it is possible to have your pictures on an external hard drive, which is displayed as E: on Unix, this drive might be /home/user/pictures.

The pwd command prints the working directory. Since there are many places to lose in a growing file system, it allows you to quickly determine where the user is.

Disk space

Disk space
Disk space

Loading disk space is a gradual process that can take years. There are two commands to use to check free space and determine which files are clogging up the disk: du with disk and df without disk. They both choose the h option. To understand how full a disk is, use the UNIX filter command df.

df UNIX filter command
df UNIX filter command

To find out how space is being used, type du and limit the output of the resultfor the first 10 lines. Otherwise, it will show up in every directory on the machine, which can be too hard to understand. From this list, you can see how much space each directory consumes. Putting a few commands together put together a script that will list the top 10 directories by space usage. The command needed to sort the output is sort.

Because the MacOS version cannot process du data for human reading, use the m option to du display disk usage in megabytes, the g or k option displays data in gigabytes or kilobytes respectively. The n and r options are used to sort (sort output) in forward and reverse order, so the largest directories appear at the top of the list.

su and sudo superusers

Superusers su and sudo
Superusers su and sudo

A number of commands related to system administration. The main command for system administration is su. This means superuser and refers to the administrator or root user account. All files owned by the system are owned by this user.

Associated with it, sudo allows you to become the superuser for a single command. Why use sudo instead of su? Practice shows that this is necessary so that the user does not often use root, because of the possibility of causing irreparable harm to the system. It's best to do your best (as a regular user) and only become superuser when absolutely necessary. Getting superuser privilege, willdepend on the UNIX distribution.

Sometimes the current user does not have su permission. On some wheel systems, this means that the user must be in a group, while on other operating systems, including MacOS, the user must be in a sudoers file.

Of course, adding a user to the sudoers file requires root privileges. To do this, you need to log out of the account and log in to the administrator account. Then run sudo nano /etc/sudoers on the command line, Nano will open the sudoer file in a terminal window, ready for editing.

Move through the file in Nano using the arrow keys. To do nunez, scroll down to the User Privilege Specification section and enter the line: nunez ALL=(ALL) ALL, for root and min users.

When typing Ctrl+x, type "Yes" to save changes and exit Nano.

Extended system operators

Advanced UNIX commands will allow you to perform various tasks in UNIX, providing more options for managing data and performing actions.

File operations:

  • chmod;
  • chown;
  • basename;
  • ln - create links and symbolic links to files and directories;
  • find - search for files and directories;

System Status Commands:

  • last;
  • w;
  • who –r;
  • uname;
  • lsb_release - Find Linux Base Release (LSB) information.

Privileged access:

  • su;
  • sudo - run commands with elevated rootprivileges;
  • visudo - safe to edit /etc/sudoers.

Advanced Process Control:

  • ps –aef;
  • ptree;
  • kill;
  • nice;
  • renice;
  • pmap;
  • pfiles.

Text manipulation commands:

  • Awk;
  • Egrep;
  • Sed;
  • Tr.

File system commands:

  • Fstyp;
  • Df;
  • du.

File system management:

  • Mount;
  • Umount;
  • Fsck;
  • Growfs;
  • tune2fs - tunable file system settings (for ext2/ext3);
  • mkfs;
  • Networking;
  • iptables - manage firewall rules on Linux server;
  • netstat;
  • traceroute.

File mapping command cat

cat file display command
cat file display command

The Linux cat command is used to display the contents of text files and concatenate multiple files into a single file, unlike the UNIX ls command which lists the contents of file directories and directories. Note that cat does not accept directories.

Cat parameters are presented in the table.



cat -b

add line numbers to non-blank lines

cat -n

add line numbers to all lines

cat -s

compress emptyline by line

cat -E

show $ at the end of the line

cat -T

show ^ I instead of tabs

Examples of cat UNIX commands.

View text file data:

  • $ cat list1.txt;
  • milk;
  • bread;
  • apples;
  • $ cat list2.txt;
  • house;
  • car;
  • $.

Merge 2 text files:

  • $ cat list1.txt list2.txt;
  • milk;
  • bread;
  • apples;
  • house;
  • car;
  • $.

Merge 2 text files into another file:

  • $ cat list1.txt list2.txt > todo.txt;
  • $.

Basic search examples

Basic Search Examples
Basic Search Examples

The first Linux find example searches through the root filesystem (/) for a file named Chapter1. If it finds a file, it prints the location on the screen: find/-name Chapter1-type f -print.

On Linux and UNIX systems, the print parameter at the end of the find command is no longer needed, so you can get it like this:

  • find/-name Chapter1-type f;
  • -type f.

This option runs a search command to return only files. If not used, it will return files, directories, and other items such as named pipes and device files that match the specified name pattern. If the user does not need it, just leave the option with the command: typef.

The following find only searches /usr and /home for any file named Chapter1.txt: find/usr/home -name Chapter1.txt -type f.

To search the current directory and all subdirectories, simply use the character to refer to the current directory in the UNIX find command, for example: name Chapter1 -type f.

The following example searches the /usr directory for all files beginning with the letter Chapter. The file name can end with any other combination of characters. It will match filenames like Chapter, Chapter1, Chapter1.bad, Chapter in the life: find /usr -name "Chapter " -type f.

The following command searches the /usr/local directory for files ending in.html. These file locations are displayed: find /usr/local -name ".html" -type f.

WC to count the number of lines, words, characters

The wc-command UNIX and Linux is used to find out the number of newline counts, number of words, bytes and count characters in files specified by file arguments. Command syntax wc:

wc [options] filenames

The following are the options and usage provided by the command.

  • wc -l: prints the number of lines in the file.
  • wc -w: Prints the number of words in the file.
  • wc -c: displays the number of bytes in the file.
  • wc -m: prints the number of characters from the file.
  • wc -L: Prints only the length of the longest line in the file.

Basic example wc:

Wc command withoutpassing any parameter displays the main result of the tecmint.txt file. The three numbers below are 12 (number of lines), 16 (number of words), and 112 (number of bytes) of the file.

[root @ tecmint ~]wc tecmint.txt 12 16 112 tecmint.txt.

To count the number of lines in a file, use the l option, which prints the number of lines from the given file. Let's say the following UNIX command will show the number of lines in a file. In the output, the first name is given as count and the second field is the filename.

[root @ tecmint ~]wc -l tecmint.txt 12 tecmint.txt.

To count the words in a file, enter the following command:

[root @ tecmint ~]wc -w tecmint.txt 16 tecmint.txt.

When using the c and m options with the wc command, the total number of bytes and characters in the file will be printed:

[root @ tecmint ~]wc -c tecmint.txt 112 tecmint.txt.

[root @ tecmint ~]wc -m tecmint.txt 112 tecmint.txt.

The wc UNIX command accepts the L argument, which can be used to print the length of the number of characters in a file. Longest Scientific Linux character string in the file.

[root @ tecmint ~]wc -L tecmint.txt 16 tecmint.txt.

Display a line of text echo

Echo is a fundamental command of the UNIX system, also used by most other operating systems that offer the string. It is often used in scripts, files, and as part of individual commands when you may need to paste text. Many shells such as bash, ksh, and csh implement echo as a built-in command.




Don't output trailing newline


Enable interpretation of backslash escape sequences (see list below)


Disable interpretation of backslash escape sequences (this is the default)


Display help message and exit


Display exit information and exit


Literal backslash character ()


Warning (BELL symbol)


Return one position.


Don't create any additional results after this.

To print the string "Hello world!", use the UNIX console command:

  • $ echo "Hello world!".
  • output: Hello world!.

Execute shell commands from vi

Executing shell commands from vi
Executing shell commands from vi

You can run UNIX commands and view their output without leaving vi, and you can also paste its output into a file you are editing.

Start up and use the shell just like a regular UNIX environment, and then exit the shell andback to vi.

The type of shell to run is determined by the $ SHELL variable of the UNIX command. To run another, you need to set the vi shell option. Return to using vi by typing exit or Ctrl-D. To paste the output from into a file, right after the cursor:


The vi UNIX command is interesting when used for documentation purposes where output examples need to be included.

UNIX makes an excellent platform for utility servers such as Domain Name System or DNS, Dynamic Host Configuration Protocol or DHCP, and Web servers. Its architecture saves resources for real applications, which need to be used not only to boot the operating system itself. UNIX also provides a stable and secure platform for applications that do not require direct interaction with the operating system.

Popular topic

Editor's choice

  • Restore Skype account: step by step instructions, return access to your account
    Restore Skype account: step by step instructions, return access to your account

    Don't know how to recover your Skype account? Or do you want to know your friend's Skype password? The article discusses several ways to restore the user's page, as well as recommendations for storing and selecting pin codes

  • Why can't I follow on Instagram? All possible reasons
    Why can't I follow on Instagram? All possible reasons

    We subscribe to people with a specific goal - to find friends, like-minded people of interest, to learn something new for ourselves. And sometimes it is very strange to see that the Instagram system does not allow you to "follow" the profile you are interested in. This error occurs quite often, no one is immune from this trouble. Let's analyze the main reasons why Instagram does not allow you to subscribe to people

  • How to find out who "liked" a person on Instagram. Proven Methods
    How to find out who "liked" a person on Instagram. Proven Methods

    Everyone who is trying to start the path of a blogger or has already achieved some success in this field, hopes that the content that he shares with readers will not be left without attention. The main indicator of page popularity is “likes”. “Thumbs up” is also put when they want to attract the attention of potential subscribers

  • How to restore a channel on YouTube: detailed instructions, simple and effective tips
    How to restore a channel on YouTube: detailed instructions, simple and effective tips

    This article describes how to restore a channel on YouTube after deleting it. To understand this task, it will be useful to familiarize yourself with some terminology. There is a difference between deleting and blocking a YouTube account

  • How to remove a contact from "Vatsap" and how to block an unwanted interlocutor
    How to remove a contact from "Vatsap" and how to block an unwanted interlocutor

    WhatsApp is a popular messenger. It has many features that users are not even aware of. One of these is the ability to block contacts. It helps to get rid of annoying interlocutors. And how to remove a contact from WhatsApp and how to block it? You can perform these actions in different ways