New to Linux? Maybe you’re looking to switch to Linux full time or learning how to operate a VPS. Below I have compiled a list of beginner Linux commands with examples to get you started. These commands will lay the foundation required to use the Linux system in more advanced ways. Let’s get started.
Print working directory. This command lists where you are in the file system. The top of the Linux file system starts with / and then branches out like a tree from there. The pwd command is useful when you have no idea where you are on the system.
Change directories. The same as clicking through your folders on a Mac or Windows machine. This command works with both relative and absolute paths.
Lists files in a directory. Exactly the same as opening up a folder on Mac or Windows and seeing all the files. By itself, the command will list all the files in the current directory. You can also list the contents of a relative or absolute path.
|-a||Lists all files including hidden ones|
|-l||Long listing. Includes additional info like permissions and timestamps|
You are familiar with the traditional way of copying files on a GUI (graphical user interface.) This typically involves dragging files from one window to another or executing a right click copy/paste. Using the cp command you can execute the same process a lot faster. Here we copy the “file1” file from the current directory into the /home/2cf/documents directory.
|-r||Copy in recursive mode (copy both files AND directories)|
Creates a folder in the current or supplied directory
|-p||Create the parent directories if they don't exist|
Removes a file when used by itself and deletes directories when used with the -r switch. Be careful with this one. You don’t want to accidentally delete any important files!
Move or rename files. In the example below, we rename “documents” to “mydocuments”
determines the file type of a file. Very useful for identifying cryptic files on a Linux system. As you explore Linux you will come across files of mysterious types. Use the file command to expand your knowledge of these files.
concatenates files and displays their output. In other words, the cat command reads the contents of a file right onto your terminal. This is a quick way to read a file without actually opening it in an editor.
Clears the terminal screen. All the output on the terminal can become overwhelming and confusing. Use the clear command to wipe the slate clean! Note that clear doesn’t actually delete anything. It simply clears the output generated by any commands you have ran.
Prints the user currently logged in to the system. Not sure who’s account you are using? You can always verify the current operator with the whoami command.
man is an interface to the Linux manual. The manual contains complete information on every command and utility available on the Linux system. If you are wondering what a certain command does you can read the manual. In the old days when n00bs asked the veterans about a particular command, they were instructed to RTFM – Read the F’n manual! They were, of course, speaking of the man command.
Reboots the system.
Brings the system down. When used without any parameters, the default action is to bring the system down into single user mode (run-level 1) immediately. This mode logs off any users currently logged into the system and prevents them from logging in. To execute a full system power down, you must use the -h option and specify a time:
Time can also be specified with a +n where “n” is the minutes before you want the system to shutdown. Here we tell the system to execute a full power down in 5 minutes.
Becoming familiar with these commands is a great start to learning how to use the Linux system. You now have everything you need to manipulate files, navigate the file system, and do some basic system administration tasks. Best of all, you have the man command. All of these commands have advanced options that I did not cover in this beginners guide. Using man, you can dive deep into the commands that interest you and learn more.