As of writing this, Linux has a worldwide market share of 2.68% on desktops, but over 90% of all cloud infrastructure and hosting services run in this operating system. For this reason alone, it is crucial to be familiar with popular Linux commands. Show
According to the 2020 StackOverflow survey, Linux is the most-used operating system by professional developers, with an impressive 55.9% of the market share. It isn’t just a coincidence. Linux is free and open-source, has better security than its competitors, and boasts a powerful command line that makes developers and power users more effective. You also have access to a powerful package manager and a bunch of development tools like DevKinsta. Whether you’re an experienced Sysadmin or a Linux newcomer, you can take advantage of this guide. Let’s begin! What Is a Linux Command?A Linux command is a program or utility that runs on the command line. A command line is an interface that accepts lines of text and processes them into instructions for your computer. Any graphical user interface (GUI) is just an abstraction of command-line programs. For example, when you close a window by clicking on the “X,” there’s a command running behind that action. A flag is a way we can pass options to the command you run. Most Linux commands have a help page that we can call with the flag 7. Most of the time, flags are optional.View plans An argument or parameter is the input we give to a command so it can run properly. In most cases, the argument is a file path, but it can be anything you type in the terminal. You can invoke flags using hyphens ( 8) and double hyphens ( 9), while argument execution depends on the order in which you pass them to the function.Did you know that 90% of all cloud infrastructure and hosting services use Linux? 🤯 For this reason alone, it is crucial to be familiar with popular Linux commands. ⬇️Click to Tweet The Most-Used Linux CommandsBefore jumping into the most-used Linux commands, make sure to fire up a terminal. In most Linux distributions, you would use Ctrl + Alt + T to do so. If this isn’t working, search in your application panel for “terminal.” The Linux terminal emulator.Now let’s dive into the 40 most-used Linux commands. Many of these have multiple options you can string to them, so make sure to check out the commands’ manual. 1. cd /home/kinsta/Documents/Videos0 Command 0 is probably the first command every Linux user typed in their terminal. It allows you to list the contents of the directory you want (the current directory by default), including files and other nested directories.
It has many options, so it might be good to get some help by using the 2 flag. This flag returns all the flags you can use with ls.For example, to colorize the output of the 0 command, you can use the following: The colorized ls command.Now the 0 command output is colorized, and you can appreciate the difference between a directory and a file.But typing 0 with the color flag would be inefficient; that’s why we use the 6 command.2. cd /home/kinsta/Documents/Videos6 CommandThe 6 command lets you define temporary aliases in your shell session. When creating an alias, you instruct your shell to replace a word with a series of commands.For example, to set 0 to have color without typing the 0 flag every time, you would use:
As you can see, the 6 command takes one key-value pair parameter: 2. Note that the value must be inside quotes.If you want to list all the aliases you have in your shell session, you can run the 6 command without argument. The alias command.3. cd4 CommandAs the name suggests, the 4 command aims to remove an 6 from the already defined aliases. To remove the previous 0 alias, you can use:
4. cd8 CommandThe 8 command stands for “print working directory,” and it outputs the absolute path of the directory you’re in. For example, if your username is “john” and you’re in your Documents directory, its absolute path would be: 0.To use it, simply type 8 in the terminal:
5. cd ..2 CommandThe 2 command is highly popular, along with 0. It refers to “change directory” and, as its name suggests, switches you to the directory you’re trying to access.For instance, if you’re inside your Documents directory and you’re trying to access one of its subfolders called Videos, you can enter it by typing:
You can also supply the absolute path of the folder:
There are some tricks with the 2 command that can save you a lot of time when playing around with it:1. Go to the home folder
2. Move a level up
3. Return to the previous directory 06. cd ..6 CommandIt’s so easy to copy files and folders directly in the Linux terminal that sometimes it can replace conventional file managers. To use the 6 command, just type it along with the source and destination files: 1You can also copy entire directories by using the recursive flag: 2Remember that in Linux, folders end with a forward slash ( 8).7. cd ..9 CommandNow that you know how to copy files, it’ll be helpful to know how to remove them. You can use the 9 command to remove files and directories. Be careful while using it, though, because it’s very difficult (yet not impossible) to recover files deleted this way.To delete a regular file, you’d type: 3If you want to delete an empty directory, you can use the recursive ( 01) flag: 4On the other hand, to remove a directory with content inside of it, you need to use the force (-f) and recursive flags: 5InfoBe careful with this — you can erase a whole day of work by misusing these two flags! 8. ls --color=auto02 CommandYou use the 02 command to move (or rename) files and directories through your file system.To use this command, you’d type its name with the source and destination files: 6To utilize absolute paths, you’d use: 7…where 04 is the directory you’re currently in.You also can use 02 to rename files while keeping them in the same directory: 89. ls --color=auto06 CommandTo create folders in the shell, you use the 06 command. Just specify the new folder’s name, ensure it doesn’t exist, and you’re ready to go.For example, to make a directory to keep all of your images, just type: 9To create subdirectories with a simple command, use the parent ( 08) flag: 010. ls --color=auto09 CommandAnother essential Linux command is 09. It displays the manual page of any other command (as long as it has one).To see the manual page of the 06 command, type: 1You could even refer to the 09 manual page: 2The manual page of “man.”11. ls --color=auto13 CommandThe 13 command allows you to update the access and modification times of the specified files.For example, I have an old file that was last modified on April 12th: Old date.To change its modification date to the current time, we need to use the 15 flag: 3Now the date matches today’s date (which at the time of writing was August 8th). New dateNonetheless, most of the time, you won’t use 13 to modify file dates, but rather to create new empty files: 412. ls --color=auto17 CommandThe 17 command lets you change the mode of a file (permissions) quickly. It has a lot of options available with it.The basic permissions a file can have are:
One of the most common use cases for 17 is to make a file executable by the user. To do this, type 17 and the flag 21, followed by the file you want to modify permissions on: 5You use this to make scripts executable, allowing you to run them directly by using the 04 notation.13. ls --color=auto04 CommandMaybe the 04 notation isn’t a command itself, but it’s worth mentioning in this list. It lets your shell run an executable file with any interpreter installed in your system directly from the terminal. No more double-clicking a file in a graphical file manager!For instance, with this command, you can run a Python script or a program only available in .run format, like XAMPP. When running an executable, make sure it has executable (x) permissions, which you can modify with the 17 command.Here’s a simple Python script and how we would run it with the 04 notation: 6Here’s how we’d convert the script into an executable and run it: 714. ls --color=auto27 CommandThe 27 command does exactly what its name suggests: With it, you can end a shell session and, in most cases, automatically close the terminal you’re using: 815. ls --color=auto29 CommandThis command stands for “superuser do,” and it lets you act as a superuser or root user while you’re running a specific command. It’s how Linux protects itself and prevents users from accidentally modifying the machine’s filesystem or installing inappropriate packages. Sudo is commonly used to install software or to edit files outside the user’s home directory: 9It’ll ask you for the administrator’s password before running the command you typed after it. 16. ls --color=auto30 CommandAs you may guess, the 30 command lets you power off your machine. However, it also can be used to halt and reboot it.To power off your computer immediately (the default is one minute), type: 0You can also schedule to turn off your system in a 24-hour format: 1To cancel a previous 30 call, you can use the 33 flag: 217. ls --color=auto34 Command 34 is an interactive process viewer that lets you manage your machine’s resources directly from the terminal. In most cases, it isn’t installed d by default, so make sure to read more about it on its download page.Sign Up For the NewsletterWant to know how we increased our traffic over 1000%?Join 20,000+ others who get our weekly newsletter with insider WordPress tips! Subscribe Now 3The “htop” interface.18. ls --color=auto36 CommandThe unzip command allows you to extract the content of a .zip file from the terminal. Once again, this package may not be installed by default, so make sure you install it with your package manager. Here, we’re unpacking a .zip file full of images: 419. ls --color=auto37, ls --color=auto38, ls --color=auto39 commandsNo matter which Linux distribution you’re using, it’s likely that you use package managers to install, update, and remove the software you use every day. You can access these package managers through the command line, and you’d use one or another depending on the distro your machine is running. The following examples will install GIMP, a free and open source software usually available in most package managers: 1. Debian-based (Ubuntu, Linux Mint) 52. Red Hat-based (Fedora, CentOS) 63. Arch-based (Manjaro, Arco Linux) 720. ls --color=auto40 CommandThe 40 command displays defined text in the terminal — it’s that simple: 8The echo commandIts primary usage is to print environmental variables inside those messages: 921. ls --color=auto42 Command 43, short for “concatenate,” lets you create, view, and concatenate files directly from the terminal. It’s mainly used to preview a file without opening a graphical text editor: 0The cat command.22. ls --color=auto44 CommandWith 44, you can take a look at the processes your current shell session is running. It prints useful information about the programs you’re running, like process ID, TTY (TeleTYpewriter), time, and command name. 1The ps command.In case you want something more interactive, you can use 34.23. ls --color=auto47 CommandIt’s annoying when a program is unresponsive, and you can’t close it by any means. Fortunately, the 47 command solves this kind of problem.Simply put, 47 sends a TERM or kill signal to a process that terminates it.You can kill processes by entering either the PID (processes ID) or the program’s binary name: 2Be careful with this command — with 47, you run the risk of accidentally deleting the work you’ve been doing.24. ls --color=auto51 Command 51 is the most popular networking terminal utility used to test network connectivity. 51 has a ton of options, but in most cases, you’ll use it to request a domain or IP address: 325. ls --color=auto54 Command 54 is a free and open source terminal text editor that’s in used since the ’90s. It lets you edit plain text files using efficient keybindings.Some people consider it difficult to use — exiting Vim is one of the most-viewed StackOverflow questions — but once you get used to it, it becomes your best ally in the command line. To fire up Vim, just type: All Kinsta hosting plans include 24/7 support from our veteran WordPress developers and engineers. Chat with the same team that backs our Fortune 500 clients. Check out our plans! 4The vim text editor.26. ls --color=auto56 CommandIf you’re struggling to remember a command, 56 comes in handy. This command displays an enumerated list with the commands you’ve used in the past: 5The history command.27. ls --color=auto58 Command 58 allows you to change the passwords of user accounts. First, it prompts you to enter your current password, then asks you for a new password and confirmation.It’s similar to any other change of password you’ve seen elsewhere, but in this case, it’s directly in your terminal: 6The passwd commandBe careful while using it — you don’t want to mess up your user password! 28. ls --color=auto60 CommandThe 60 command outputs the full path of shell commands. If it can’t recognize the given command, it’ll throw an error.For example, we can use this to check the binary path for Python and the Brave web browser: 729. ls --color=auto62 CommandIf you ever wanted a file to be almost impossible to recover, 62 can help you with this task. This command overrides the contents of a file repeatedly, and as a result, the given file becomes extremely difficult to recover.Here’s a file with little content in it: File to shred.Now, let’s have 62 do its thing by typing the following command: 8Overwritten content.If you want to delete the file right away, you can use the 65 flag: 930. ls --color=auto66 Command 66 (opposite of more) is a program that lets you inspect files backward and forward: 0The less command.The neat thing about 66 is that it includes more and 54 commands in its interface. If you need something more interactive than 42, 66 is a good option.31. ls --color=auto72 CommandSimilar to 42, 72 prints the contents of a file with one major caveat: It only outputs the last lines. By default, it prints the last 10 lines, but you can modify that number with 75.For example, to print the last lines of a large text file, you’d use: 1The tail command.To view only the last four lines: 2tail four lines.32. ls --color=auto76 CommandThis one is complementary to the 72 command. 76 outputs the first 10 lines of a text file, but you can set any number of lines you want to display with the 75 flag: 3The head command.33. ls --color=auto80 CommandGrep is one of the most powerful utilities for working with text files. It searches for lines that match a regular expression and print them: 4The grep command.You can count the number of times the pattern repeats by using the 33 flag: 534. ls --color=auto82 CommandThe 82 command (short for “who am i”) displays the username currently in use: 6You would get the same result by using 40 and the environmental variable $USER: 735. ls --color=auto85 Command 85 prints a single-line description of any other command, making it a helpful reference: 836. ls --color=auto87 CommandWc stands for “word count,” and as the name suggests, it returns the number of words in a text file: 9Let’s breakdown the output of this command:
If you only need the number of words, use the 88 flag: 037. ls --color=auto89 Command 89(short for “Unix name”) prints the operative system information, which comes in handy when you know your current Linux version.Most of the time, you’ll be using the 91 (–all) flag, since the default output isn’t that useful: 138. ls --color=auto92 CommandNeofetch is a CLI (command-line interface) tool that displays information about your system — like kernel version, shell, and hardware — next to an ASCII logo of your Linux distro: 2The neofetch command.In most machines, this command isn’t available by default, so make sure to install it with your package manager first. 39. ls --color=auto93 CommandThe 93 command searches for files in a directory hierarchy based on a regex expression. To use it, follow the syntax below: 3To search for a file named long.txt in the current directory, enter this: 4To search for files that end with a .py (Python) extension, you can use the following command: 540. ls --color=auto95 Command 95 (World Wide Web get) is a utility to retrieve content from the internet. It has one of the largest collections of flags out there.Here’s how you would download a Python file from a GitHub repo: 6Linux Commands Cheat SheetWhenever you want a quick reference, just review the below table: CommandUsage 0Lists the content of a directory 6Define or display aliases 4Remove 6 definitions 8Prints the working directory 2Changes directory 6Copies files and directories 9Remove files and directories 02Moves (renames) files and directories 06Creates directories 09Displays manual page of other commands 13Creates empty files 17Changes file permissions 04Runs an executable 27Exits the current shell session 29Executes commands as superuser 30Shutdowns your machine 34Displays processes and resources information 36Extracts compressed ZIP files 37, 38, 39Package managers 40Displays lines of text 42Prints file contents 44Reports shell processes status 47Terminates programs 51Tests network connectivity 54Efficient text editing 56Shows a list of previous commands 58Changes user password 60Returns the full binary path of a program 62Overwrites a file to hide its contents 66Inspects files interactively 72Displays last lines of a file 76Displays first lines of a file 80Prints lines that match patterns 82Outputs username 85Shows single-line descriptions 87Word count files 89Displays OS information 92Displays OS and hardware information 93Searches for files that follow a pattern 95Retrieves files from the internet
As of 2020, Linux was the most-used operating system by professional developers 😲 Learn the 40 most-used commands and start taking advantage of this powerful system with this post🚀Click to Tweet SummaryIt can take some time to learn Linux, but once you master some of its tools, it becomes your best ally, and you won’t regret choosing it as your daily driver. One of the remarkable things about Linux is that even if you’re an experienced user, you’ll never stop learning to be more productive using it. There are a lot more helpful Linux commands. If we’ve left something out, please share your favorite Linux commands in the comments below! Get all your applications, databases and WordPress sites online and under one roof. Our feature-packed, high-performance cloud platform includes:
Test it yourself with $20 off your first month of Application Hosting or Database Hosting. Explore our plans or talk to sales to find your best fit. Which of the following Linux commands utilities can be used to edit a wireless connection's configuration settings?Which of the following Linux commands/utilities can be used to edit a wireless connection's configuration settings? C. There is a utility called ifconfig that is used to see and edit network configuration files. It has a counterpart, iwconfig, that works with wireless connection configuration files.
What are the utility commands in Linux?Top 50 Linux Commands You Must Know as a Regular User.. The ls command in Linux.. The pwd command in Linux.. The cd command in Linux.. The mkdir command in Linux.. The cp and mv commands.. The rm command in Linux.. The touch command in Linux.. What is file utilities in Linux?These are the Linux commands which help you to create, delete, rename, move, copy, edit and perform other related activities on Linux files.
Which of the following Linux commands can be used to create file?The easiest way to create a new file in Linux is by using the touch command. The ls command lists the contents of the current directory. Since no other directory was specified, the touch command created the file in the current directory.
|