Regístrese ahora para una mejor cotización personalizada!

The first 5 Linux commands every new user should learn

Mar, 07, 2024 Hi-network.com
5 penguins
Raimund Linke/Getty Images

I rememberwhen 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 why I believe every new user should learn these five Linux commands.

ls

Thelscommand lists the contents of a directory. When you runls,it will show you all folders and files within the directory, andnothing else. Butlsdoes 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-loption (which stands forlong list). When you issue the commandls -l(which can also be run asll), 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-aoption, which stands forall. If you have hidden directories (directories that start with a .), the only way to see them is to run the commandls -a. You could even combine l and a, with the commandls -la, which will show the details of all files and folders in your directory.

cd

Thecdcommand 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 commandcd Documents. 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 commandcd ~/Documents. Or, if you're in any directory on your drive, you could change to your home directory with the commandcd.

rm

Is there a file or folder you want to delete? If so, you can use thermcommand. Say, for instance, you have /home/colette/test.txt and want to delete it. For that task, the command would berm /home/colette/test.txt. Of course, you could use the shorthand,rm ~/test.txt.

Also: Thebest Linux distros for beginners

To delete a folder is a bit trickier. If you have the folder ~/test and issue the commandrm ~/test, you will receive an error. That error will occur because you have to use ther option (for recursive). This option deletes the contents of test, and then deletes the folder. Thecommand for that process isrm -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 berm -ir ~/test.

cp

If you need to copy a file, you use thecpcommand. 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 likecp~/text.txt ~/Documents/. You should note that I didn't have to 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 can create a copy in a different directory andrename it like this: cp ~/test.text ~/Documents/test1.txt.

mv

The mvcommand stands formoveand 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 ismv~/test.txt ~/Documents/. Notice that I didn't add the file name to the second half of the command. It's very much like thecp 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, say you want to rename ~/test.txt to ~/testing.txt. For that process, the command ismv ~/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 (akaman pages), which are available on your system. You can view the man page for each command by runningman COMMAND(where COMMAND is the name of the command you want to read about). Soman 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.

tag-icon Etiquetas calientes: tecnología

Copyright © 2014-2024 Hi-Network.com | HAILIAN TECHNOLOGY CO., LIMITED | All Rights Reserved.