Linux has taken over the enterprise. It runs the backbone for many of the largest companies. It's one of the biggest players in big data. If you're serious about moving up the IT ladder, at some point, you're going to have to know Linux.
And although the Linux GUI tools are now as good as those available for any other platform, some tasks will require a bit of command-line knowledge. But where do you begin? You start off where every Linux newbie should... with what I believe are five of the most important commands for new Linux admins to learn.
Note: This article is also available as an image gallery.
You probably saw this coming from a mile away. The man command is where a good portion of your Linux education will begin. That's right. Built into the very platform you're using is a massive collection of help files ready to get you up to speed on any command you need. Say, for instance, you want to get up to speed on the ip command (the replacement for ifconfig). Issue the command man ip and you'll get all the information you need to learn that command.
Nearly every command on your system should have a man page, all of which are set up to follow a specific standard. You'll get the command structure, information about all the flags, switches, and options, command syntax, a history of the command, and related commands. If you've ever hear someone say RTFM... consider that "m" to be "man page."
That Windows command dir? It doesn't exist in Linux. Instead, we have ls. This command will list the contents of a directory for you. But don't think it's limited to listing filenames. Oh no. You can run ls with switches, like ls -l,to get a long description of filenames (permissions, file size, timestamp, etc.). You can even issue the command ls -la to include hidden files.
If you want to do a recursive listing (so you can also see what's tucked away within those folders), issue the command ls -R. If you want to find out more about what ls can do for you, guess what... RTFM!
The mv command does one thing and it does it well: It moves files and folders. Okay, that's not entirely true. The mv command is also really good at renaming files and folders. Of course, if you look at it the right way, renaming a file or folder is actually just moving from one location to another... and giving it a different name. In other words, mv test test1 moves the test file into the same directory, only it gives it a different name.
Use this tool with caution. For instance, suppose you have two files: test and test1. You want to rename test and you accidentally issue the command mv test test1. This command will overwrite your existing test1 file with the contents of test. To avoid that you can use the -n option, which will prevent mv from overwriting an existing file. So mv -n test test1 will not overwrite test1 with test. This is a precaution everyone should take.
If you need to delete a file or folder, the rm command is what you need. As with the mv command, you should be careful with the rm command. In fact, because of the power rm wields, the developer included a switch that makes the command interactive. If you issue the command rm -i test you will be asked if you want to remove the regular file test. If you answer y, the file will be deleted. A simple n will prevent rm from removing the file.
If you need to delete a folder, you have to include the R switch (for recursive). To delete the folder TEST, you would issue the command rm -iR TEST. If you have an old Linux system about to recommissioned (and you have all the data from the drive), you can have a little fun by issuing the command rm -rf / as the root user (or using sudo) and watch the entire contents of the machine vanish before your eyes. Don't do this. Really... don't.
Say you need to edit a fairly lengthy configuration file, but you only need to edit a single line—one that contains the string of characters LOCAL_LINUX_LOCALE (that's not actually a thing). You probably don't want to have to look, line by line, for that entry. Instead, why not use the power of grep?
Suppose that config file is named app.conf. To check the file for the string, you could issue the command grep LOCAL_LINUX_LOCALE app.conf. The results would list the string, highlighted for easy spotting. And what if you needed to know the exact line number that contains the string? Just add the -n switch, and it will print out the line number:
grep -n LOCAL_LINUX_LOCALE app.conf
The old image of every Linux user needing to know commands is long dead. Desktop Linux has come a long way from the days when it depended upon the command line. Even so, if you plan to administer Linux servers, you'll want to master some command line basics.
Have you run across other commands that have been particularly useful? Share you experiences and advice with fellow TechRepublic members.
Jack Wallen is an award-winning writer for TechRepublic and Linux.com. He’s an avid promoter of open source and the voice of The Android Expert. For more news about Jack Wallen, visit his website jackwallen.com.