I remember when I started using Linux in the late 1990s. Back then, using the command line wasn’t optional. If you worked with the open-source operating system, you spent time in the terminal.
Using the command line in the past was challenging because there wasn’t as much help as today. I was pretty much on my own. Thankfully, I struggled through and became proficient. Of course, the irony of me putting in all that hard work is that using the command line isn’t a requirement now.
Also: Thinking about switching to Linux? 10 things you need to know
Yet I remember learning those first, simple commands. Those foundations made it easier for me to continue onward and created a solid base from which to build.
Although these commands are rather rudimentary, you should take your first steps and use the five commands suggested below. Not only will they be the most helpful as you get started, but they’ll also be the commands you use the most.
Let me explain which five Linux commands I believe every new user should learn.
ls
The ls command lists the contents of a directory. When you run ls, it will show you all folders and files within the directory, and nothing else. But ls does have a couple of tricks up its sleeve. For example, say you want to see the details of the files and folders in that directory, you would add the -l option (which stands for long list). When you issue the command ls -l (which can also be run as ll), you see the permissions, owner, group, size, and creation date/time of each file and folder.
Also: 5 Microsoft Edge features that might make it my new favorite Linux browser
Another handy addition is the -a option, which stands for all. If you have hidden directories (directories that start with a .), the only way to see them is to run the command ls -a. You could even combine l and a, with the command ls -la, which will show the details of all files and folders in your directory.
cd
The cd command is what you use when you need to change directories. For example, say you are in your home directory (sometimes noted ~/ or /home/USERNAME, where USERNAME is your Linux username) and want to change to the Documents directory. For that, you would run the command cd Documents. But what if you want to change into the Documents directory in ~/, but you’re not in ~/? That’s an easy switch. Since ~/ is shorthand for /home/USERNAME/, you could issue the command cd ~/Documents. Or, if you’re in any directory on your drive, you could change to your home directory with the command cd.
rm
Is there a file or folder you want to delete? If so, you can use the rm command. Say, for instance, you have /home/colette/test.txt and want to delete it. For that task, the command would be rm /home/colette/test.txt. Of course, you could use the shorthand, rm ~/test.txt.
Also: The best Linux distros for beginners
To delete a folder is a bit trickier. If you have the folder ~/test and issue the command rm ~/test, you will receive an error. That error will occur because you have to use the r option (for recursive). This option deletes the contents of test, and then deletes the folder. The command for that process is rm -r ~/test.
There’s one more trick. If you want to be extra careful when deleting folders, you could use the interactive method, which asks you before it deletes anything. For that, the command would be rm -ir ~/test.
cp
If you need to copy a file, you use the cp command. For example, let’s say you have the file ~/test.txt and you want to make a copy of it. You can’t create a copy of a file and name it the same thing (unless you’re creating the copy in a different directory). If you want to place the copy in a different directory, the command is something like cp ~/text.txt ~/Documents/. You should note that I didn’t specify a file name in the second half of the command. However, if you want to place the copy in the same directory, you should specify the new file name like this: cp ~/test.txt ~/test1.txt. You could also create a copy in a different directory and rename it like this: cp ~/test.text ~/Documents/test1.txt.
mv
The mv command stands for move and makes it possible to move a file or folder from one location to another. If you want to move ~/test.txt into the Documents directory, that command is mv ~/test.txt ~/Documents/. Notice that I didn’t add the file name to the second half of the command. It’s very much like the cp command in that regard.
Also: There’s a new coolest Linux distribution ready to wow you
The mv command is also what you use when you want to rename a file (without making a copy). For instance, you want to rename ~/test.txt to ~/testing.txt. For that process, the command is mv ~/test.txt ~/testing.txt. And, yes, you could also move and rename the file simultaneously, like this: mv ~/test.txt ~/Documents/testing.txt.
One final note
I’ve shown you the basics of each command. When you first start using Linux, that’s all you’ll need. However, as you keep going, you might need to use the more advanced features of those commands. The best place to start is the manual pages (aka man pages), which are available on your system. You can view the man page for each command by running man COMMAND (where COMMAND is the name of the command you want to read about). So man ls, man cd, man rm, man cp, and man mv. Those manual pages detail all of the options available for each command.
Enjoy taking your first steps with the Linux command line.
+ There are no comments
Add yours