قالب وردپرس درنا توس
Home / Tips and Tricks / 37 Important Linux Commands That You Should Know

37 Important Linux Commands That You Should Know



  Laptop laptop terminal with stylized text
fatmawati achmad zaenuri / Shutterstock.com

Are you new to Linux or just a little rusty? Here are all the commands you need to know. Think of this as a necessary reference for the Linux terminal. This also applies to the MacOS command line.

The basic tool for the terminal

Linux contains a large number of commands, but we have chosen 37 of the most important ones to be presented here. Learn these commands, and you'll be much more at home at the command prompt in Linux.

Below is listed in alphabetical order. A command's position in the list is not representative of its usability or simplicity. For the last word on the command, see its man pages. The command man is in our list, of course ̵

1; it is brief for "manual".

first alias

With the alias command, you can give your own name to a command or a series of commands. You can then write your short name, and the shell will execute the command or sequence of commands for you.

  alias cls = clear 

Here is created an alias called cls . There will be another name for clear . When writing cls it will clear the screen just as if you had written clearly . Your alias saves some keystrokes, certainly. But if you often move between Windows and the Linux command line, you can find yourself typing the Windows cls command on a Linux machine that doesn't know what you mean. Now it will know.

Alias ​​can be much more intricate than the simple example. Here is an alias named pf (for process finds) which is just a little more complex. Note the use of quotation marks around the command sequence. This is required if the command sequence has spaces in it. This alias uses the command ps to list the ongoing processes and then moves them through the command grep . Command grip searches for entries in the release of ps that match the command line parameter $ 1 .

  alias pf = "ps -e | grep $ 1" 

If you want to discover the process ID (PID) of the shutter process or to find out if shutter even went to run - you can use the alias like this. Type pf a space and the name of the process you are interested in:

  pf shutter 

 alias command in terminal window

Alias ​​defined on the command line will die with the terminal window. When you close it, they are gone. To make your aliases always available to you, add them to the .bash_aliases file in your home directory.

2nd cat

The command cat (short for "concatenate") lists the contents of files to the terminal window. This is faster than opening the file in an editor, and there is no chance of you accidentally changing the file. To read the contents of the file .bash_log_out type the following command while the home list is your current workbook, by default:

  cat .bash_logout 

 cat. bash_logout command in a terminal window

With files longer than the number of rows in your terminal window, the text will be whipping too fast for you to read. You can whip the output of cat through less to make the process more manageable. With less you can scroll forward and backward through the file with the up and down arrows, the PgUp and PgDn keys and the start and end buttons. Type q to quit less.

  cat .bashrc | less 

 cat .bashrc | Less in a terminal window

3. cd

The cd command changes your current directory. In other words, you move to a new location in the file system.

If you change to a directory that is in your current directory, you can simply type cd and the name of the second directory

  cd work 

If you change to a directory elsewhere within the file management file system, give the path to the directory a leading /.

 cd / usr / local / bin 

To quickly return to your home directory, use (tilde) the character as the directory name.

  cd ~ 

 cd command in a terminal window

Here is another trick: You can use the double point symbol .. to represent the parent of the current directory. You can type the following command to go up in a directory:

  cd .. 

Imagine that you are in a directory. The parent directory has other directories in it, as well as the directory you are in. To switch to one of the other directories you can use .. symbol to shorten what you have to write.

  cd ../games

cd command with .. in a terminal window

4. chmod

The command chmod specifies the file state flags on a file or folder. The flags define who can read, write to or execute the file. When you list files with the -l (long format) option, you see a series of characters that look like

  -rwxrwxrwx 

If the first character is a - ] object is a file, if it is a d the object is a directory. The rest of the string is three sets of three characters. From the left, the first three file permissions for the owner represent the three three represent the file permissions of the group and the highest three characters represent the permissions of others . In each set there is a read a w stands for write and a x stands for run.

If r w or x characters are present as file state is granted. If the letter is not present and a - is displayed instead, this file state is not granted.

One way to use chmod is to give the permissions you want to give to the owner, group and others as a 3-digit number. The left figure represents the owner. The middle number represents the group. The highest number represents the others. The numbers you can use and what they represent are listed here:

  • 0: No permission
  • 1: Execute permission
  • 2: Write permission
  • 3: ]] Write and run permissions
  • 4: Read eligibility
  • 5: Read and run permissions
  • 6: Read and write permissions
  • 7: Read, write and execute permissions

Look at our example.txt file we can see that all three sets are rwx . This means that everyone has read, write and run rights with the file.

To set the state to read, write and execute (7 from our list) for the owner read and write from our list) for the group and read and run (5 from our list) for others we would need to use the numbers 765 with chmod command:

  chmod-R 765 example.txt 

[1945941] chmod command in a terminal window " width="644" height="275" src="/pagespeed_static/1.JiBnMqyl6S.gif" onload="pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);" onerror="this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);"/> [19659006] To set permissions to read, write and run (7 from our list) for owner and read and write (6 from our list) for the group and for others we would need to use the numbers 766 with ] chmod command:

  chmod 766 example.txt 

5. chown

The command chown allows you to change the owner and group owner to a file. Lists our example.txt file with ls -l we can see dave dave in the file description. The first of these indicates the name of the file owner, which in this case is the user dave . The second record shows that the name of the group owner is also dave . Each user has a default group created when the user is created. That user is the only member of that group. This shows that the file is not shared with other user groups.

You can use chown to change the owner or group or both files. You must enter the owner and group, separated by a : character. You must use sudo . To keep dave as the owner of the file, but to set mary as a group owner, use this command:

  sudo chown dave: mary example.txt 

 chown command in a terminal window [19659006] To change both owner and group owner to mary, you would use the following command:

  sudo chown mary: mary example.txt 

To change the file so that dave is once the file owner and group owner, use this command: [19659009] sudo chown dave: dave example.txt

6. curl

The command curl is a tool for retrieving information and files from Uniform Resource Locators (URLs) or Internet addresses.

The Curl command cannot be provided as a standard part of your Linux distribution. Use apt-get to install this package on your system if you use Ubuntu or another Debian based distribution. On other Linux distributions, use your Linux distribution package management tool instead.

  sudo apt-get install curl 

Suppose you want to download a single file from a GitHub archive. There is no official support for this. You have to clone the entire repository. With curl we can download the file we want on our own.

This command downloads the file for us. Note that you must enter the name of the file to save it, with the option -o (output). If you do not, the contents of the file are quickly rolled into the terminal window but are not saved on your computer.

  curl https://raw.githubusercontent.com/torvalds/linux/master/kernel/events/ core.c -o core.c 

If you do not want to see the download information, use the -s (silent) option.

  curl -s https://raw.githubusercontent.com/torvalds/linux/master/kernel/events/core.c -o core.c 

 curl in a terminal window

7th df

The command df shows the size, used space and free space on the computer's mounted file system. Two of the most useful alternatives are -h (human readable) and -x (excluding) alternatives. The human readable option shows the size in Mb or Gb instead of in bytes. The exclusion option lets you tell df to discount file systems you are not interested in. For example, squashf's pseudo-file system is created when you install a program with [19659000]] [19659000] [19659000] DF command in a terminal window "width =" 644 "height =" 265 "src =" / pagespeed_static / 1. JiBnMqyl6S.gif "onload =" pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon (this); "onerror =" this.onerror = null; pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon (this); "/>

RELATED: you look at free disk space and disk utilization From the Linux terminal

8th diff

The command diff compares two text files and shows the differences between them.There are many options for customizing

The -y (side by side) option shows the line differences side by side, and the -w (width) option allows you to specify the maximum line width to use to avoid wraparound lines, the two files is called alpha1.txt and alpha2.txt in this example. - suppressed common lines prevent diff from noting matching lines, so that you focus on the lines that have differences.

  diff -y -W 70 alpha1.txt alpha2.txt - suppress-common-lines 

 diff command in a terminal window

RELATED: How to compare two text files in the Linux terminal

9. echo

The command echo writes (echoes) a string text to the terminal window.

The command below will print the words "A text string" in the terminal window.

  echo A string of text 

The command echo can display the value of environmental variables, for example $ USER $ HOME and ] $ PATH and ] $ PATH and environment variables. These contain the values ​​of the user's name, the user's home directory, and the path of matching commands when the user writes something on the command line. " width="650" height="300" src="/pagespeed_static/1.JiBnMqyl6S.gif" onload="pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);" onerror="this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);"/>

echo $ USER

  echo $ HOME 
  echo $ PATH 

echo command in a terminal window " width="644" height="225" src="/pagespeed_static/1.JiBnMqyl6S.gif" onload="pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);" onerror="this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);"/>

The following command will cause a diaper to be issued. The -e (escape code) option interprets the saved character as a "bell" character.

  echo-e "

The command echo is also invaluable in shell scripts. A script can use this command to generate visible output to indicate progress or results of the script that it executes.

10th exit

Exit command closes a terminal window, exits the execution of a shell script or logs you out of an SSH remote access.

  Exit 

 Exit Command in a Terminal Window ]

11. find

Use the command to find to track files that you know exist unless you remember where you put them. You must tell find where to start searching from and what it is looking for. In this example, is. matches the current folder and the name name tells find to look for files with a name that matches the search pattern.

You can use wildcards where * represents any sequence of characters and ? represents any single character. We use * such * to match all file names containing the sequence "such". This would match words like legs, stones and alone.

  find. -name * ones * 

 find command in a terminal window

As we can see, find a list of hits. One of them is a directory called Ramones. We can tell find to limit the search to files only. We do this with the option type with the parameter f . The parameter f stands for files.

  find. -type f-name * ones * 

If you want the search to be insensitive use -iname (insensitive name) option.

  find. -iname * wild * 

12. finger

The finger command gives you a brief dump of information about a user, including the time of the user's last login, the user's home directory, and the user's full name.

] finger command in a terminal window

13. free

The free command gives you a summary of memory usage with your computer. It does so for both the most important random access memory (RAM) and exchange memory. The alternative -h (human) is used to provide human friendly numbers and entities. Without this option, the numbers are presented in bytes.

  free -h 

free command in a terminal window " width="644" height="165" src="/pagespeed_static/1.JiBnMqyl6S.gif" onload="pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);" onerror="this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);"/>

14. grep

The grep tool searches for lines that contain a search pattern. When we looked at the alias command, we used grip to search the result of another program, ps . The command grep can also search the contents of the files. Here we search for the word "train" in all text files in the current directory.

  grep train * .txt 

The output lists the name of the file and displays the lines that match. The matching text is highlighted.

 grep command in a terminal window

The function and clean utility of grip definitely guarantee that you check out their man's side.

15. groups

Groups [19659000] groups specify the command in a terminal [19659000] 19659007] 16. gzip

The command gzip compresses files. By default, it removes the original file and leaves you with the compressed version. To maintain both original and compressed versions, use the -k (keep) option. Gzip -k core.c  gzip command in a terminal window [19659007] 17. head

The command header gives you a list of the first 10 lines of a file. To see fewer or more rows, use the -n (number) option. In this example, we use the head with its standard of 10 lines. We then repeat the command after only having five lines.

head-command in a terminal window " width="644" height="380" src="/pagespeed_static/1.JiBnMqyl6S.gif" onload="pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);" onerror="this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);"/> 18. history

The history command lists the commands you have previously issued on the command line. You can repeat some commands from your story by writing an exclamation mark ! and the number of the command from the history list.

! 188

 history command in a terminal window

Writing two exclamation marks repeats your previous command.

  !! 

19th kill

command kill allows you to terminate a process from the command line. You do this by providing process ID (PID) for the process to death . Don't kill processes. You must have a good reason to do so. In this example, we should pretend that the shutter program is locked. To find the PID of the shutter we use our ps and grip tricks from the section on the command alias above. We can search for the shutter process and get its PID as follows:

  ps -e | 

Once we have determined PID-1692 in this case, we can kill it as follows:

  kill 1692 

 kill command in a terminal window

20. less

lesser less lets you view files without opening an editor. It's faster to use, and there's no chance of you accidentally changing the file. With less you can scroll forward and backward through the file with the up and down arrows, the PgUp and PgDn keys and the start and end buttons. Press the Q key to exit from less .

To display a file, give its name to less as follows:

  less core.c [19659010]   smaller command in a terminal window  

You can also direct the output from other commands to less . To view the output of ls for a list of the entire hard drive, use the following command:

  ls -R / | less 

 smaller command in a terminal window

Use / to search forward in the file and use ? to search backwards.

21. ls

This may be the first command the majority of Linux users encounter. It lists the files and folders in the directory you specify. By default, ls in the current directory. There are many options you can use with ls and we highly recommend reviewing their man page. Some common examples are shown here.

To list files and folders in the current directory:

  ls 

To list the files and folders in the current directory with a detailed list, use -l (long) options:

To use human file sizes, include the option -h (human):

  ls-lh 

files use the option -a ( all files):

  ls-lha 

 ls command in a terminal window

22. man

The human command shows the "man sides" of a command in less . The men's pages are the user's guide for that command. Because uses less to display the man pages, you can use the search functions on less .

For example, to see the man pages of chown use the following command:

  man chown 

Use the Up and Down arrows or PgUp and PgDn to scroll through the document. Press q to exit the man page or press h for help.

 man command in a terminal window

23. mkdir

The command mkdir allows you to create new directories in the file system. You must enter the name of the new directory into mkdir . If the new directory will not be within the current directory, you must enter the path to the new directory.

Use these two commands to create two new directories in the current directory called "invoices" and "quotes".

  mkdir invoices 
  mkdir quote 

 mkdir command in a terminal window

To create a new directory called "2019" in the "invoices" directory, use this command: [19659009] mkdir invoices / 2109

If you are going to create a directory, but its publishing directory does not exist, you can use -p (parents) option to have mkdir create all the compulsory parental directories also. In the following command, we create the directory "2019" inside the "annual" directory in the "quotes" directory. The "annual" directory does not exist, but we may have mkdir create all the specified directories at once:

  mkdir -p quote / annual / 2019 

The "annual" directory is also created.

24th etc.

The command etc. allows you to move files and directories from directory to directory. It also makes it possible to rename files.

To move a file, you must tell etc. where the file is and where you want it to be moved to. In this example, we move a file named apache.pdf from the directory "~ / Document / Ukulele" and place it in the current directory, represented by the single .

  mv ~ / Documents / Ukulele / Apache.pdf. 

 mv command in a terminal window

To rename the file, move it to a new file with a new name.

  etc. Apache.pdf The_Shadows_Apache.pdf 

The file shift and rename action could have been achieved in one step:

  etc. ~ / Documents / Ukulele / Apache.pdf ./The_Shadows_Apache.pdf[19659058] 25. passwd 

The passwd command lets you change the password of a user. Just type passwd to change your own password.

You can also change the password for another user account, but you must use sudo . You will be asked to enter the new password twice.

  sudo passwd mary 

the passwd command in a terminal window " width="644" height="145" src="/pagespeed_static/1.JiBnMqyl6S.gif" onload="pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);" onerror="this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);"/>

26. ping

The ping command lets you verify that you have a network connection with another network device. It is usually used to troubleshoot network problems. ping 192.168.4.18

The ping command will run until you stop it with Ctrl + C.

 ping in a terminal window

Here's what happens here:

  • The device at IP address 192.168.4.18 responds to our ping requests and sends back packets of 64 bytes.
  • Sequence numbering of the Internet Control Messaging Protocol (ICMP) allows us to check for missed answers (dropped packets). The TTL digit is "time to live" for a package. Each time the package goes through a router, it is (supposedly) reduced by one. If it reaches zero, the package is thrown away. The purpose of this is to prevent network logging problems from flooding the network.
  • The time value is the duration of the tour from your computer to the device and the back. Simply put, the lower this time the better.

If you want to ask ping to run for a certain number of ping attempts, use the -c (count) option. [19659009] ping -c 5 192.168.4.18

To hear a ping, use the -a (audible) option. Ping -a 192.168.4.18

27. ps

ps ps lists ongoing processes. By using ps without any alternatives, it makes it possible to list the processes that are running in the current shell.

  ps 

 ps command in a terminal window

To see all the processes related to a particular user, use the -u (user) option. This is likely to be a long list, so for convenience, it is by less .

  ps -u dave | less 

 ps command in a terminal window

To see each process running, use the -e (each process) option:

  ps -e | less 

28. pwd

Pwd

<img class = "alignnone size-full wp-image-412481" data-pagespeed-lazy-src = "https://www.howtogeek.com/wp-content/uploads/2019/ 04 / xtop_commands_38.png.pagespeed.gp + jp + jw + pj + ws + js + rj + rp + rw + ri + cp + md.ic.5vx_VxFEhf.png "alt =" the pwd command in a terminal window

pwd

<img class = "alignnone size-full wp-image-412481" data-pagespeed-lazy-src = "https://www.howtogeek.com/wp-content/uploads/2019/04/xtop_commands_38. png.pagespeed.gp + jp + jw + pj + ws + js + rj + rp + rw + ri + cp + md.ic.5vx_VxFEhf.png "alt =" pwd command in a terminal window ” width=”644″ height=”95″ src=”/pagespeed_static/1.JiBnMqyl6S.gif” onload=”pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);” onerror=”this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);”/>] [19659007] 29th shutdown

The shutdown command lets you turn off or restart your Linux system.

Using Shutdown without any parameters turns off the computer in one minute.

closure command in a terminal window

To turn off immediately, use now the parameter.

  Close Now 

 Close Now

You can also schedule a shutdown and inform all logged in users of the current shutdown. To let the command know when to shut it off, you give it a moment. This may be a certain number of minutes from now, for example +90 or an exact time, such as 23:00 . All SMS messages you send are sent to logged in users.

  Turn off at 23:00 Shutdown tonight at 23:00, save your job and log out before it! 

 Closing 23:00 with message

To cancel a shutdown, use the -c (cancel) option. Here we have planned a shutdown for fifteen minutes from and now changed us.

  Turn off +15 Turn off in 15 minutes! 
  Turn off -c 

 Shutdown - Cancel command Exit]

RELATED: How to restart or shut down Linux with the command line

30 °. SSH

Use the ssh command to connect to a Linux computer on your computer and log in to your account. To be able to connect, you must enter your username and IP address or domain name on the remote computer. In this example, the user logs Mary into the computer at 192.168.4.23.

  ssh mary@192.168.4.23 

 ssh command in a terminal window

Her username and password are verified and accepted, and she is logged in. Note that her prompt has been changed from "Nostromo" to "howtogeek."

Mary issues the w command to list the current users on the "howtogeek" system. She is listed as connected from pts / 1, which is a pseudo-terminal slave. It is not a terminal directly connected to the computer.

To end the session, the mary types end and return to the shell of the "Nostromo" computer.

  w [19659097] w 

 w and terminating commands in a terminal window

31. sudo

Kommandot sudo krävs när du utför åtgärder som kräver root eller superuserbehörigheter, t.ex. byte av lösenord för en annan användare.

 sudo passwd mary 

 passwd-kommandot i en terminalfönster

32. svansen

Kommandot svansen ger dig en lista över de sista 10 raderna i en fil. Om du vill se färre eller fler rader använder du alternativet -n (nummer). I det här exemplet använder vi svansen med sin standard på 10 linjer. Vi upprepar sedan kommandot efterfråga endast fem linjer.

 svanskärna.c 
 svans-n 5 core.c 

 svängkommando i ett terminalfönster

33. tjära

Med kommandot tjära kan du skapa en arkivfil (även kallad tarball) som kan innehålla många andra filer. Detta gör det mycket bekvämare att distribuera en samling filer. Du kan också använda tjära för att extrahera filerna från en arkivfil. Det är vanligt att fråga tjära för att komprimera arkivet. Om du inte begär komprimering skapas arkivfilen okomprimerad.

För att skapa en arkivfil måste du berätta tjära vilka filer som ska inkluderas i arkivfilen och det namn du önskar Arkivfilen ska ha.

I det här exemplet kommer användaren att arkivera alla filer i katalogen Ukulele, som finns i den aktuella katalogen.

 ls kommandot i terminalfönstret [19659006]They have used the -c (create) option and the -v (verbose) option. The verbose option gives some visual feedback by listing the files to the terminal window as they are added to the archive. The -f (filename) option is followed by the desired name of the archive. In this case, it is songs.tar.

tar -cvf songs.tar Ukulele/

tar -cvf command in a terminal window

The files are listed to the terminal window as they are added to the archive file.

There are two ways to tell tar that you want the archive file to be compressed. The first is with the -z (gzip) option. This tells tar to use the gzip utility to compress the archive once it has been created.

It is usual to add “.gz” as suffix to this type of archive. That allows anyone who is extracting files from it to know which commands to pass to tar to correctly retrieve the files.

tar -cvzf songs.tar.gz Ukulele/

tar -cvzf command in a terminal window

The files are listed to the terminal window as they are added to the archive file as before, but the creation of the archive will take a little longer because of the time required for the compression.

To create an archive file that is compressed using a superior compression algorithm giving a smaller archive file use the -j (bzip2) option.

tar -cvjf songs.tar.bz2 Ukulele/

tar -cvjf command in a terminal window

Once again, the files are listed as the archive is created. The -j option is noticeably slower than the -z option.

If you are archiving a great many files, you must choose between the -z option for decent compression and reasonable speed, or the -j option for better compression and slower speed.

As can be seen in the screenshot below, the “.tar” file is the largest, the “.tar.gz” is smaller, and the “.tar.bz2” is the smallest of the archives.

ls command in a terminal window

To extract files from an archive file use the -x (extract) option. The -v (verbose) and -f (filename) options behave as they do when creating archives. Use ls to confirm which type of archive you are going to extract the files from, then issue the following command.

ls
tar -xvf songs.tar

ls and tar -xvf commands in a terminal window

The files are listed as they are extracted. Note that the Ukulele directory is also recreated for you.

To extract files from a “.tar.gz” archive, use the -z (gzip) option.

tar -xvzf songs.tar.gz

tar -xvzf command in a terminal window

Finally, to extract files from a “.tar.bz2” archive use the -j option instead of the -z (gzip) option.

tar -xvjf songs.tar.bz2

tar -xvjf command in a terminal window

RELATED: How to Extract Files From a .tar.gz or .tar.bz2 File on Linux

34. top

The top command shows you a real-time display of the data relating to your Linux machine. The top of the screen is a status summary.

The first line shows you the time and how long your computer has been running for, how many users are logged into it, and what the load average has been over the past one, five, and fifteen minutes.

The second line shows the number of tasks and their states: running, stopped, sleeping and zombie.

The third line shows CPU information. Here’s what the fields mean:

  • us: value is the CPU time the CPU spends executing processes for users, in “user space”
  • sy: value is the CPU time spent on running system “kernel space” processes
  • ni: value is the CPU time spent on executing processes with a manually set nice value
  • id: is the amount of CPU idle time
  • wa: value is the time the CPU spends waiting for I/O to complete
  • hi: The CPU time spent servicing hardware interrupts
  • si: The CPU time spent servicing software interrupts
  • st: The CPU time lost due to running virtual machines (“steal time”)

The fourth line shows the total amount of physical memory, and how much is free, used and buffered or cached.

The fifth line shows the total amount of swap memory, and how much is free, used and available  (taking into account memory that is expected to be recoverable from caches).

top command in a terminal window

The user has pressed the E key to change the display into more humanly digestible figures instead of long integers representing bytes.

The columns in the main display are made up of:

  • PID: Process ID
  • USER: Name of the owner of the process
  • PR: Process priority
  • NI: The nice value of the process
  • VIRT: Virtual memory used by the process
  • RES: Resident memory used by the process
  • SHR: Shared memory used by the process
  • S: Status of the process. See the list below of the values this field can take
  • %CPU: the share of CPU time used by the process since last update
  • %MEM: share of physical memory used
  • TIME+: total CPU time used by the task in hundredths of a second
  • COMMAND: command name or command line (name + options)

(The command column didn’t fit into the screenshot.)

The status of the process can be one of:

  • D: Uninterruptible sleep
  • R: Running
  • S: Sleeping
  • T: Traced (stopped)
  • Z: Zombie

Press the Q key to exit from top.

RELATED: How to Set Process Priorities With nice and renice on Linux

35. uname

You can obtain some system information regarding the Linux computer you’re working on with the uname command.

  • Use the -a (all) option to see everything.
  • Use the -s (kernel name) option to see the type of kernel.
  • Use the -r (kernel release) option to see the kernel release.
  • Use the -v (kernel version) option to see the kernel version.
uname -a
uname -s
uname -r
uname -v

uname command in a terminal window

36. w

The w command lists the currently logged in users.

w

w command in a terminal window

37. whoami

Use whoami to find out who you are logged in as or who is logged into an unmanned Linux terminal.

whoami

whoami command in a terminal window

RELATED: How to Determine the Current User Account in Linux

That’s Your Toolkit

Learning Linux is like learning anything else. You’re going to need some practice before your familiar with these commands. Once you have these commands at your fingertip, you’ll be well along the path to proficiency.

There’s an old joke—probably as old as Unix itself—that says the only command you need to know is the man command. There’s a glimmer of truth in that, but some of the man pages are impenetrable without an introduction. This tutorial should give you the introduction you need.




Source link