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

37 Important Linux Commands You Should Know



  Linux terminal on a laptop with stylized text
fatmawati achmad zaenuri / Shutterstock.com

Are you a Linux freshman or just a bit rusty? Here are all the commands you need to know. Think of this as an essential reference for the Linux terminal. This also applies to the macOS command line.

The Essential Toolkit for the Terminal

Linux contains a large number of commands, but we have selected 37 of the most important commands here. Learn these commands and you will be much more at home at the Linux prompt.

The following list is arranged alphabetically. The position of a command in the list is not representative of its usefulness or simplicity. The last word about using a command can be found in the man pages. The command man is of course in our list ̵

1; it is the abbreviation for "manual".

. 1 Alias ​​

Use the Alias ​​command to give a command or command string its own name. You can then enter your nickname and the shell will run the command or command string for you.

  alias cls = clear 

This creates an alias named cls . It will be another name for clear . If you enter cls the screen is cleared as if you had entered as . Your alias stores a few keystrokes. However, if you frequently switch between Windows and Linux command lines, on a Linux machine, type cls cls which does not know what you mean. Now it will know.

Aliases can be much more complicated than this simple example. Here's an alias called pf (for process finding), which is just a little bit more complex. Note the use of quotation marks around the command sequence. This is required if the command sequence contains spaces. This alias uses the command ps to list the running processes, and then directs them through the command grep . The command grep looks for entries in the output of ps that match the command line parameter $ 1 . Alias ​​pf = "ps -e | grep $ 1"

If you want to determine the process ID (PID) of the process or if you want to find out if the -shutter is executed at all, you can use the alias like this. Enter pf a space and the name of the process you are interested in:

  pf shutter 

 alias command in terminal window

Aliase defined in the command line becomes die with the terminal window. If you close it, they are gone. To have your aliases always available, add them to .bash_aliases in your home directory.

. 2 cat

The command cat (short for "concatenate") lists the contents of files in the terminal window. This is faster than opening the file in an editor, and you can not accidentally change the file. To read the contents of your file .bash_log_out enter the following command while the home directory is your current working directory (by default):

  cat .bash_logout 

 cat. Bash_logout command in a terminal window

For files that are longer than the number of lines in your terminal window, the text will pass too fast for you. You can whistle the output from cat to less to make the process more manageable. Press less to scroll through the file using the up and down arrow keys, the PgUp and PgDn keys, and the Home and End keys. Enter q to finish the number.

  cat .bashrc | less 

 kat.bashrc | Less in a terminal window

3. cd

The command cd changes your current directory. In other words, you will be moved 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 other directory

  cd work 

If you are in another directory within To change the directory structure of the file system, type the path to the directory with a leading /.[19659009dlcd/usr/local/bin

an to return quickly. In your home directory, use the character ~ (tilde ) as a directory name.

  cd ~ 

 cd command in a terminal window

Here is another trick: You can use the double-dot symbol. to represent the parent directory of the current directory. You can enter the following command to call a directory:

  cd .. 

Imagine that you are in a directory. The parent directory contains other directories and the directory you are currently in. To switch to one of these other directories, you can use the .. . Icon to shorten what you need to type.

  cd ../games[19659010Menucommandwithaterminalwindow"width="644"height="75"src="/pagespeed_static/1JiBnMqyl6Sgif"onload="pagespeedlazyLoadImagesloadIfVisibleAndMaybeBeacon(this);"onerror="thisonerror=null;pagespeedlazyLoadImagesloadIfVisibleAndMaybeBeacon(this);">

chmod

The command chmod sets the file permission flags for a file or folder If you list files with the option -l (long format), you will see a string that looks like

  -rwxrwxrwx 

if the first character is a - is] the element is a file, if it is a d the element is a directory, the rest of the string consists of three groups of three characters the first three represent the owner's file permissions [19659039] the middle three represent the file permissions of the group and the far right three characters the permissions for others . In each sentence is a r for reading, a w is for writing, and a x is for execute. [19659] If the r w or x character exists, the file is granted. If the letter does not exist and instead appears - this file permission will not be granted.

One way to use chmod is to grant the permissions that you want to give to the owner, group, and other than a 3-digit number. The number on the far left represents the owner. The middle digit stands for the group. The right digit stands for the others. The digits that you can use and what they represent are listed here:

  • 0: No permission
  • 1: execute permission
  • 2: write permission
  • 3: ] Write and Execute Permissions
  • 4: Read Permission
  • 5: Read and Execute Permissions
  • 6: Read and Write Permissions
  • 7: Read Executing Write and Permissions

If you look at our example.txt file, we can see that all three character sets are rwx . That is, everyone has rights to the file with read, write and execute rights.

To set the permission to read, write and execute (7 from our list) for the owner Read and write (6 from our list) to the group and read and execute (5 from our list) for other we would need to use the digits 765 with the chmod ] command:

  chmod -R 765 example.txt 

 chmod command in a terminal window

To set the permission to read, write and execute (7 from our list) for owner and read and write (6 from our list) for the group and for the others [19659039] we would have to use the digits 766 with chmod command:

  chmod 766 example.txt 

5. chown

Use the chown command to change the owner and group owner of a file. If we list our example.txt file with ls -l we can see dave dave in the file description. The first of these specifies the name of the file owner. In this case, it is the user dave . The second entry shows that the name of the group owner is also dave . Each user has a default group that is created when the user is created. This user is the only member of this 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 of a file. You must specify the name of the owner and the group, separated by a character : . You must use sudo . To keep dave as the owner of the file, but to set mary as the group owner, use this command:

  sudo chown dave: mary example.txt 

 Chown command in a terminal window [19659006] For both the owner and Also to change the group owner in Mary, you would use the following command:

  sudo chown mary: mary example.txt 

To change the file so that dave is again the file owner and the group owner, use it Command:

  sudo chown dave: dave example.txt 

6. curl

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

The command curl may not be provided as a standard part of your Linux distribution. Use apt-get to install this package on your system if you are using Ubuntu or any other Debian-based distribution. Instead, use the package management tool of your Linux distribution on other Linux distributions.

  sudo apt-get install curl 

For example, suppose you want to retrieve a single file from a GitHub repository. There is no officially supported way. You are forced to clone the entire repository. However, with curl we can retrieve the desired file ourselves.

This command gets the file for us. Note that you must specify the name of the file in which you want to save the file. Use the option -o (output). If you do not, the contents of the file in the terminal window will scroll quickly but will not be saved to your computer.

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

If you do not see download progress information you want to use -s (mute).

  curl -s https://raw.githubusercontent.com/torvalds/linux/master/kernel/events/core.c -o core.c [196909010]  Curl in a terminal window  

7th df

The df command displays size, used space, and available space in the attached file systems on your computer.

Two of the most useful options are -h (human-readable) and -x (exclude). The human-readable option displays the sizes in Mb or Gb instead of bytes. With the exclusion option, you can tell df which file systems you are interested in that you are not interested in. For example, the squashfs pseudo-file systems created when you install an application with . Snap command.

  df -h -x squashfs 

 df command in a terminal window

RELATED: Showing Free Space and Disk Usage From the Linux Terminal

8. diff

The command diff compares two text files and shows the differences between them. There are many options to customize the ad to your needs.

The option -y (side by side) displays the line differences side by side. Use the option -w (width) to specify the maximum line width that should be used to avoid line breaks. The two files are called alpha1.txt and alpha2.txt in this example. The common-line suppression prevents diff from listing the matching rows, so you can focus on the rows that have differences.

  diff -y -W70 alpha1.txt alpha2.txt --suppress common lines 

 diff command in a terminal window

RELATED: Compare by two text files in the Linux terminal

9. echo

The command echo prints a text string into the terminal window.

The following command prints the words "one text string" in the terminal window.

  Echo A String 

The echo command can display the value of environment variables, such as: For example, $ USER $ HOME and ] environment variables $ PATH . These include the values ​​of the name of the user, the home directory of the user, and the path searched for matching commands when the user types something on the command line.

  echo $ USER 
  echo $ HOME 
  echo $ PATH 

 Echo command in a terminal window

The following command causes a beep to sound. The option -e (escape code) interprets the escaped character as a bell.

  echo -e " a" 

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

10th exit

The exit command closes a terminal window, stops the execution of a shell script, or logs you out of an SSH remote access session.

  exit 

 Exit command in a terminal window

11. find

Use the find command to find files that you know exist, if you can not remember where you put them. You need to find out where to start searching and what to look for. In this example the . matches the current folder and option -name tells find to search for files with a name that matches the search pattern.

You can use wildcards where * stands for any string and for any single character. We use * one * to find each filename that contains the sequence "one". This would fit words like bones, stones and lonesome.

  find. -name * ones * 

 find command in a terminal window

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

  find. -type f -name * ones * 

If the search is case-sensitive, use the option -iname (insensitive name).

  find. -iname * wild * 

12. finger

The finger command provides a brief snapshot of information about a user, including the time the user last logged in, the user's home directory, and the user account's full name.

 Fingering in a terminal window

13. free

The command free gives you a summary of the memory usage of your computer. This is done for both random access memory (RAM) and swap memory. The option -h (human) is used to indicate humane numbers and units. Without this option, the numbers are represented in bytes.

  free -h 

 free command in a terminal window

14. grep

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

  grep train * .txt 

The output lists the name of the file and displays the corresponding lines. The associated text is highlighted.

 grep command in a terminal window

The functionality and sheer utility of grep definitely guarantees checking out the man page.

15. groups

The command groups tells you which groups a user is a member of.

  Groups dave 
  Groups Mary 

 Group command in a terminal window [19659007] 16. gzip

The command gzip compresses files. By default, the original file is removed and you receive the compressed version. To keep both the original and compressed versions, use the option -k (keep).

  gzip -k core.c 

 gzip command in a terminal window [19659007] 17. head

The command head gives you a list of the first 10 lines of a file. If you want to see fewer or more lines, use the option -n (number). In this example we use head with a standard of 10 lines. We then repeat the command and only ask for five lines.

  head-core.c 
  head -n 5 core.c 

 Header command in a terminal window

18. history

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

! Enter 188

 historical command in a terminal window

If you enter two exclamation marks, your previous command is repeated.

  !! 

19th kill

You can use the kill command to end a process from the command line. To do this, specify the process ID (PID) of the process kill . Do not kill processes arbitrarily. You have to have a good reason for that. In this example, we specify that the program for the trigger program has been discontinued.

To determine the PID of the switch we use our ps and grep trick from the section on alias above. We can search for the Shutter process and get its PID like this:

  ps -e | grep shutter. 

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

  kill 1692 

 Kill command in a terminal window

20. less

You can use the less command to view files without opening an editor. The usage is faster and you do not have the option to change the file unintentionally. With less you can use the up and down arrow keys, the PgUp and PgDn keys, and the Home and End keys to scroll through the file. Press the Q key to cancel .

To display a file, specify less as follows:

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

You can also change the output of other commands to forward less . Use the following command to view the output of ls for a listing of your entire hard disk:

  ls -R / | less 

 less command in a terminal window

Use / to search forward in the file, and to search backward.

21. ls

This could be the first command encountered by the majority of Linux users. It lists the files and folders in the directory you specified. By default, ls searches in the current directory. There are many options that you can use with ls and we strongly recommend that you review the man page. Some common examples are presented here.

To list the 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) Option: [19659009] ls -l

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

  ls -lh 

files use the option -a (all files):

  ls -lha 

 ls command in a terminal window

22. man

The command man displays the "man pages" for a command in less . The manpages are the user manual for this command. Since one uses less to display the man pages, you can use the search functions of less .

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

  man chown 

Use the up and down arrows or the PgUp and PgDn keys to navigate through the 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

You can use the mkdir command to create new directories in the file system. You must specify mkdir the name of the new directory. If the new directory is not in the current directory, you must specify the path to the new directory.

To create two new directories in the current directory named "Invoices" and "Quotation marks", use the following two commands:

  mkdir invoices 
  mkdir quotes 

 mkdir command in a terminal window

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

If you want to create a directory, the parent However, if the directory does not exist, you can use the option -p (parent) to have mkdir . Also, create all required parent directories. In the following command we create the directory "2019" in the directory "annual" in the directory "quotes". The directory & # 39; annual & # 39; is not present, but we can create mkdir all specified directories simultaneously:

  mkdir -p quotes / annual / 2019 

The "annual" directory is also created

24. mv

You can use the mv command to move files and directories from directory to directory. You can also rename files.

To move a file, you must tell mv where the file is and where to move it. 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 . characters.

  mv ~ / Documents / Ukulele / Apache.pdf. 

 mv command in a terminal window

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

  mv Apache.pdf The_Shadows_Apache.pdf 

The action to move and rename files could be accomplished in one step:

  mv ~ / Documents / Ukulele / Apache.pdf ./The_Shadows_Apache.pdf __] 25. passwd 

Use the command passwd to change the password for a user. Just enter passwd to change your own password.

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

  sudo passwd mary 

 passwd command in a terminal window

26. ping

You can use the ping command to verify that you have a network connection with another network device. It is often used to troubleshoot network problems. To use ping specify the IP address or computer name of the other device.

  ping 192.168.4.18 

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

 Ping in a terminal window

Here's What Happens:

  • The device at IP address 192.168.4.18 responds to our ping requests and returns 64-byte packets
  • Internet Control Messaging Protocol (ICMP) sequence numbering allows us to check for missed replies ( dropped packages).
  • The TTL number is the "time to live" for a package. Each time the packet passes through a router, it is decremented by one. If it reaches zero, the package is thrown away. This is to prevent network loop problems from flooding the network.
  • The time value is the duration of the roundtrip from your computer to the device and back. Put simply, the lower this time, the better.

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

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

  ping -a 192.168.4.18 

27. ps

The command ps lists running processes. If ps is used without options, the processes running in the current shell are listed.

  ps 

 ps command in a terminal window

To display all processes Use -u (user) for a particular user. This is probably a long list, allowing for convenience pipe less .

  ps -u dave | less 

 ps command in a terminal window

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

  ps -e | less 

28. pwd

The command pwd prints the working directory (the current directory) from the root directory / directory.

  pwd 

 pwd command in a terminal window ]

29. shutdown

Use the shutdown command to shut down or restart your Linux system.

With shutdown without parameters, your computer shuts down in a minute.

shutdown

 Befehl zum Herunterfahren in einem Terminalfenster

Zum sofortigen Herunterfahren verwenden Sie den Parameter jetzt .

 Jetzt herunterfahren 

 Jetzt herunterfahren

Sie können auch Planen Sie ein Herunterfahren und informieren Sie alle angemeldeten Benutzer über das bevorstehende Herunterfahren. Damit der Befehl shutdown wissen kann, wann er heruntergefahren werden soll, geben Sie ihm eine Zeit. Dies kann eine festgelegte Anzahl von Minuten sein, wie +90 oder eine genaue Zeit wie 23:00 . Jede von Ihnen bereitgestellte Kurzmitteilung wird an angemeldete Benutzer gesendet.

 Herunterfahren 23:00 Uhr heute Nacht um 23:00 Uhr herunterfahren, Ihre Arbeit speichern und abmelden! 

 23:00 Uhr herunterfahren mit Nachricht

Verwenden Sie zum Abbrechen eines Herunterfahrens die Option -c (Abbruch). Hier haben wir ein Herunterfahren für 15 Minuten geplant - und dann unsere Meinung geändert.

 Herunterfahren +15 Herunterfahren in 15 Minuten! 
 Herunterfahren -c 

 Shutdown -c Abbruchbefehl

RELATED: Neustarten oder Herunterfahren von Linux mithilfe der Befehlszeile

30. SSH

Verwenden Sie den Befehl ssh, um eine Verbindung zu einem Linux-Remotecomputer herzustellen und sich bei Ihrem Konto anzumelden. Um eine Verbindung herzustellen, müssen Sie Ihren Benutzernamen und die IP-Adresse oder den Domänennamen des Remote-Computers angeben. In diesem Beispiel meldet sich der Benutzer mary bei 192.168.4.23 am Computer an. Sobald die Verbindung hergestellt ist, wird sie nach ihrem Kennwort gefragt.

 ssh mary@192.168.4.23 

 ssh-Befehl in einem Terminalfenster

Ihr Benutzername und Ihr Kennwort werden überprüft und akzeptiert. und sie ist eingeloggt. Beachten Sie, dass sich ihre Eingabeaufforderung von "Nostromo" in "howtogeek" geändert hat.

Mary gibt den Befehl w aus, um die aktuellen Benutzer im "howtogeek" -System aufzulisten. Sie wird als von pts / 1 verbunden aufgelistet, was ein Pseudo-Terminal-Slave ist. Das heißt, es ist kein Terminal, das direkt mit dem Computer verbunden ist.

Um die Sitzung zu beenden, verlässt Mary und wird auf dem "Nostromo" -Computer in die Shell zurückgegeben.

 w 
 ] exit 

 w und exit-Befehle in einem Terminalfenster

31. sudo

Der Befehl sudo ist erforderlich, wenn Aktionen ausgeführt werden, für die Root- oder Superuser-Berechtigungen erforderlich sind, beispielsweise das Ändern des Kennworts für einen anderen Benutzer.

 sudo passwd mary 

[19456585] passwd in a Terminalfenster " width="644" height="145" src="/pagespeed_static/1.JiBnMqyl6S.gif" onload="pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);" onerror="this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);"/>

32. tail

Mit dem Befehl tail erhalten Sie eine Auflistung der letzten 10 Zeilen einer Datei. Wenn Sie weniger oder mehr Zeilen sehen möchten, verwenden Sie die Option -n (Nummer). In diesem Beispiel verwenden wir tail mit einer Standardeinstellung von 10 Zeilen. Wir wiederholen dann den Befehl und fordern nur fünf Zeilen auf.

 tail core.c 
 tail -n 5 core.c 

 tail-Befehl in einem Terminalfenster

33. tar

Mit dem Befehl tar können Sie eine Archivdatei (auch Tarball genannt) erstellen, die viele andere Dateien enthalten kann. Dies macht es viel bequemer, eine Sammlung von Dateien zu verteilen. Sie können auch tar verwenden, um die Dateien aus einer Archivdatei zu extrahieren. Es ist üblich, tar zu bitten, das Archiv zu komprimieren. Wenn Sie keine Komprimierung anfordern, wird die Archivdatei unkomprimiert erstellt.

Zum Erstellen einer Archivdatei müssen Sie tar angeben, welche Dateien in die Archivdatei aufgenommen werden sollen und welchen Namen Sie haben möchten Archivdatei zu haben.

In diesem Beispiel archiviert der Benutzer alle Dateien im Ukulele-Verzeichnis, das sich im aktuellen Verzeichnis befindet.

 ls-Befehl im Terminalfenster [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