Linux

10 command-line tools that refuse to die

Despite the abundance of GUIs, the command line still offers more power, flexibility, and control for certain tasks.

Some people think the command line is an outdated mode of usage and administration. Others say they couldn't live without it. I'm caught somewhere in the middle. There are certain commands for which I have faithful GUI tools. But there are other commands I will never be without, so long as there is a command prompt to take them.

What commands could possibly be irreplaceable? Is there really such an animal? You bet there is. Some of them are Linux/UNIX commands, some of them are Windows commands, and some of them are platform-independent.

But why commands? Simple. Commands give you the most control over the task at hand. Generally speaking, there is less restriction on what a tool can do when it's run as a command. This power, naturally, comes with a price -- users needs a better understanding of a tool when they run it as a command instead of via a GUI. That's okay, because the power and usefulness these tools offer make up for having to learn a few switches.

1: Ping

Ping is the workhorse go-to tool anytime there's a network issue. When I can't get connected, the first tool I use is ping. We all know ping; we all love ping. It's a universal tool, available on nearly every platform. Anyone who isn't familiar with ping should have their IT card revoked and their hand repeated slapped with a Cat5 cable.

2: Traceroute

Traceroute lets you trace a network route and measure transit delays from hop to hop. This tool is second to ping when you're trying to resolve issues with a network connection. Where ping tells you if you're up, traceroute can tell you where there's a problem. The only disadvantage of Traceroute is that you must have a working network connection to use it. Yes, there are GUIs for this. But the command-line version can't be beat.

3: Killall

Killall is one mean mother of a tool. In Linux land, if an application is locked and you can't get it to go away, Killall will get you out of that bind. It's powerful, so it should (as you would expect) be used with caution. And yes, you can kill processes through various GUI tools. But none wields the mighty power of the killall command.

4: Taskkill

Taskkill is the Windows version of killall. As an Acronis administrator, I have found taskkill to be invaluable. There are times when the mms.exe command simply can't be stopped in the Services GUI. When that's the case, the only way to kill mms.exe (short of rebooting the server) is to use taskkill. Of course, you should always try to kill an application through the Task Manager (or a service through Services) first. But when that fails, try taskkill.

5: Tar

Tar is the bread-and-butter archival tool for UNIX and Linux. There are others, but none (in my opinion) is as good as tar. Tar is an incredibly useful tool that can be used in scripts (such as backup scripts), cron jobs, and much more. Linux offers a number of other archival tools (bunzip2, zip, gzip, etc.), but tar is the one I immediately go to every time.

6: Chmod

Chmod is the Mac Daddy for UNIX/Linux permissions. If you have any intention of being a UNIX/Linux administrator, you should know chmod inside and out, backward and forward. This tool will become one of your best friends, and you will use it often. Sure, you can change permissions with a GUI. But when you have to change permissions on a large scale or on files/folders that require root access, you must know chmod. Otherwise, you're going to be logging into a GUI as the root user -- and that's not a good decision to make at any time.

7: Chown

Chown is to ownership what chmod is to permissions. Every file and folder on a Linux system has an owner. Who that owner is will determine who can access the file or folder. The chown command is another must-know command for any UNIX/Linux administrator. Again, there are GUIs for this command. But the command itself is far more flexible and faster to use than firing up a GUI and hoping you can do everything you need to do.

8: Chkdsk

Chkdsk is a valuable Windows tool for administrators. At some point (and this is practically inevitable), the file system integrity of a machine is going to come into question. When that happens, the best tool to call up is chkdsk (Check Disk). Chkdsk can automatically repair errors and is an absolute necessity in certain situations. The command chkdsk C: /r will become your best friend in situations where disk integrity must be checked. This command will force a check upon reboot.

9: Man

Man is the command that people in Linux land refer to when they say RTFM (read the freaking manual). Man brings up a "man page" (or manual page) for a command. For example, say you need to learn about the ping command. If you type man ping, you will be greeted by the manual for the ping command. Nearly every built-in command on a Linux system has a man page and is a great place to start to learn about that command.

10: Net use

Net use is one heck of a helpful Windows command. It connects a machine to or disconnects a machine from a shared resource. But that's not all. The net use command can also display information about computer connections as well as control persistent network connections. This is one of the Windows commands that is handy to use within scripts.

Other invaluable commands?

There are thousands upon thousands of commands out there, ready for you to make use of them. Many of them have GUI equivalents that do a great job of handling the task for you. But in some cases, nothing can best the command line for power and flexibility.

What about you? What commands do you live and die by? Or do you manage to work completely off the command prompt grid?

Additional resources

About

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 getjackd.net.

124 comments
lunascii
lunascii

what about xcopy for backup? In scripts I use this daily for my most important files

sh10453
sh10453

A very good topic, but it is a terrible idea to mix Windows commands and other operating system(s) commands in the topic. There are plenty of very important Windows command-lines that can fill out this topic of 10, with plenty more to spare. I hope the next re-write of this topic would be "20 Essential Windows Command-Line Tools for IT Professionals". Thanks.

pjboyles
pjboyles

Windows commands I use alot: NBLOOKUP (kb830578) - for those still with WINS. NBTSTAT IPCONFIG NSLOOKUP NETSTAT PING TRACERT CD MD RD DEL ECHO REM @ CALL :text - labels for scrpts EXIT GOTO IF TYPE FOR - in all its iterations - "looping" plus SET - review advanced SET usage - arithmatic, substrings, substitution SETX FINDSTR - Regular expresions, grep capabilities DFSUTIL NLTEST - If you have DFS.... DSQUERY DSGET DSMOD DSMOVE DSADD DSRM XCACLS ICACLS PROMPT SCHTASKS SC - such a powerful command for service control SLEEP SUBST CMD /C - use it to prefix any external command in a script to prevent the script from ending unexpectedly. ie cmd /c myutil.exe START - good way to spin off separate items in a script CHOICE NTRIGHTS NOW - great for flagging log files POWERCFG NETSH NETDOM (errorlevls 2224, 2691 are collision errors) FTYPE ASSOC W32TIME REG - King of registry management REG /? NET - Extremely powerful see all its capabilities NET /? MKLINK FILEACL ATTRIB MSIEXEC ROBOCOPY - extremely powerful copy with logging!

wael_jabari
wael_jabari

most commands that I use and i think they should include: 1- nslookup 2- netsh 3- grep 4- adsquery

Seotop
Seotop

Me everyday use "ping" and "killall" ;)

inspiron80
inspiron80

Being worked on linux for more than a decade, I prefer to use command prompt on my windows box too. I think windows cmd is also powerful enough for managing administrative tasks..I usually refer this site http://www.windows-commandline.com for anything related to command line.

Eurotechworld
Eurotechworld

It is Wonderful and helpful information and boost any business. Thanks for sharing this information friend. vendor audits

kaizoman
kaizoman

GREP when combined with any command makes all commands more useful. If you combine GREP with AWK and KILL! You morph into a GOD, no really it's true.

mamacat
mamacat

sfc /scannow The system file checker in Windows has saved me a thousand times, yet it is not in most textbooks (I'm a tech, but I also teach this stuff). This tool examines all of the system files to be sure they are present and in the correct version. It uses a combo of installation files from the DVD and the list of installed updates to accomplish this task. Most of the greatest Linux commands are already on the list! I tell my students I want a bumper sticker that says "I love my CLI!" Command line tools and scripting make life sooo much easier.

vquangchung
vquangchung

md \\?\drive_letter:\folder_name.extension... to make a secured folder. To access it, simple press Windows+R -> type \\?\drive_letter:\folder_name.extension...\ -> enter. To remove it, use rd \\?\drive_letter:\folder_name.extension...

robmicarelli
robmicarelli

It's the most powerful and easiest way to locally and remotely manage sistems for skilled professionals. GUIs are for beginners. The shell is the past-present-future for ITs.

FSKambic
FSKambic

I would have to add the ROUTE command to the list. At least for my current position, it has most definately helped

mtorres7
mtorres7

Valuable schedulling command! at 21:00 /every:M,T,W,Th,F,S,Su shutdown -s -f -t 10

metaphysician
metaphysician

When I need to make lists of files in directories and subdirectories, this is the command I use. I import the resulting file into Excel, do a little manipulation, and I have my list.

nuno.ines
nuno.ines

This command tools are everywhere, and available at almost all time. My favorite is "sc", starting and stopping a process in a remote machine is really cool. NI

IMADJamil
IMADJamil

How many times we use CD command to change directories?? @0vidiu you have to add NETSTAT to your list ;) Commands are the kernel of any system.

chroswalt
chroswalt

With the popularity of shell based programming languages such as Ruby and PowerShell growing, the command-line is even more popular today than even the old System V days.This is due to the accessibility of the modern shell compared to the shell of yesteryear. The personal computer was born because the need to customize a system to do what you need when you want it. There will always be the need for commands as written language is more powerful and allows a end user to more creative than a simple GUI. In the future the most popular and desired features will be in the GUI, but power knowledge workers that want customization and efficiency will be using the command-line on a regular basis.

GSG
GSG

I like them because what you can do at the cmd line, is something you can write a .bat file to do for you, and you can schedule it. In unix, my favorite has to be "cp". If it wasn't for that little command, I'd have been manually recreating a bunch of complex things through a GUI that does not support copying.

subarathi04
subarathi04

I Love this command : Ping 0.0.0.0, ipconfig, sc query ex taskkill

martosurf
martosurf

"Some people think the command line is an outdated mode of usage and administration. " Yeah, they're called IGNORANTS! - including pseudo "IT staff" that runs MS Windows, OMG! >:-D

mddrcefish
mddrcefish

Some are Windows, some Unix/Linux. Why mix them up. Not everyone is a Win/Unix/Linus/Mac user. This would've been easier to sift thru if they'd been put in OS groups.

tedeansiii
tedeansiii

awk, updatedb in a cron, ipconfig /flushdns, gpupdate /f, also chkdsk sometimes will revive flash and external drive that appear to have lost all data. top, ps aux, ls -la

Per4mer001
Per4mer001

Netstat top ffmpeg for videophiles

oz penguin
oz penguin

tail and grep are two of my favourites especially when used together

lou.vaiano
lou.vaiano

# list directories starting with 'abc' from current location find . -name "abc*" -type d # Find all text files containing "abc" searching from current location find . -name "*.txt" -exec grep -in "abc" {} \; -print # Remove all text files searching from current location find . -name "*.txt" -type f -exec rm {} \; # Find all files older than 60 days old and delete them (you may want to test this on your specific flavour of *nix). find . -name "*" -type f -mtime +60 -exec rm {} \;

cquirke
cquirke

ChkDsk isn't the "best" tool to check and repair NTFS, it's the only one. It's a loose cannon; either safe but unreliable (prone to false positive errors) when run read-only without the /F, or uncontrollable if run with /F (no pre-action prompts, no undo). But there's nil else available for NTFS, or FAT32 that spans the 137G line. As to /R, that IMO should not be used at all. If you suspect the surface of the disk is failing, you should do a quick (SMART details) check, back up, and then do a surface check that does not get bogged down trying to "fix" anything, as ChkDsk /R will do. I use HD Tune for both the SMART details and surface scan; the latter tests the whole physical drive, not just the area within particular partitions or volumes. There's a step before HD Tune, if you find file system corruption, and that is to check the RAM. If the RAM is bad, it's unsafe to run anything on that system; the hard drive should be backed up and tested from within another known-good PC (but not booted there!).

Htalk
Htalk

Why list out windows and unix commands that do the same/related things as different items? You're using up your top ten too quickly instead of writing: "Killall (or TaskKill for Windows)" or "Chown (also Chgrp, Chmod)". If you grouped them, then you'd have room for more... - ssh - dig - tail - more - pico

yvonne_lau
yvonne_lau

As an application dev/support team, I find xcopy most valuable in the cases where the same configuration file needed to be copied to multiple similar locations. Using GUI will means transversing the folders many, many times. It is far easier to issue to a single command.

h4rb1ng3r
h4rb1ng3r

I have a suite of batch files that I use PSEXEC with so I can do a whole bunch of things to remote PC's quickly and easily. From remotely enabling RDP access to installing apps silently, PSEXEC allows me to do stuff that I would otherwise need to talk user through. And since when is "cmd" a command line tool? It *IS* the command line!

Datacommguy
Datacommguy

Although some aren't MS system commands, there are some of the old DOS or DOS add-on utility commands which still work and fill an occasional need. SWEEP was one, although I haven't tried it in W7 yet. FC to compare a couple files. ATTR to play with file attributes that Windows doesn't let you manage. Using the 'pipe' symbol to pipe the output of one command into another on the same command line. And the combination of CD and DIR to let you see files and directories that Windows translates into something it thinks you want to see (check your recycle bin some time).

glnz
glnz

Love these articles - with LogMeIn Free and the Shutdown /r /f command, I have been able to update and install needed security items on my wife's laptop remotely, while she is traveling on business. But I remain a non-tech total novice. Is there a pdf manual that lists all of these, at least for Win XP Pro SP3, with instructions and samples? And maybe even explains what the hell they do? Thanks !!

beep54
beep54

Does anyone other than me use sfc in Windows. Seems to work in conjunction with chkdsk, although I've often found than when sfc actually does find a problem, it cannot necessarily fix it. I think it then needs a copy of the OS complete with the latest Service Packs on say a DVD and who actually has that?

csumbler
csumbler

How often trying to clean a virus out of a Windows machine. GUI message "that service is running" You know and can see the virus. Windows won't allow a running file to be deleted. Anti virus says it must reboot to remove it, but you can see it reload before the anti virus, Catch 22. Command line use a manual delete problem solved. Has helped me out countless times.

Barmace
Barmace

I have had times where I have a Server or PC locked up and I have to reboot it but for some reason I can not RDP to it Shutdown /m \\'SERVERNAME' /r /f /t 0 saved my bacon quite a few times

rickmor
rickmor

One of my favorites is diskpart followed by clean disk, it has helped me out on numerous occasions When Windows XP can't see a disk that was previously formatted as UDF. Don't automatically assume that a disk is dead just because the Windows XP disk management utility won't see it. Try diskpart first.

maszsam
maszsam

Are you kidding? A great deal of the GUI programs for monitoring machine functions are just a graphical display of the command line output. What about top? How do you know what to kill? Only people stuck in strick Microsoft mode don't need to know much about the command line. Well I use ping, ipconfig and then some commands from the start menu to call GUIs for like regedit with Microsoft. Used command line when DOS was big and now with Unix and Linux. Perfer to use command line to compile C++. That way there is no weird between you and what is going on. There is no question in my mind as a programmer, DBA, network tech and hardware tech (you can use a Linux live CD to boot with and get a full descrition of a systems hardware from the command line, very helpful in chasing down drivers) and web master that if you don't know the command line, you don't really know all that much about how a computer oprerates. If you really want to know computers, get away from Microsoft, you only learn Microsoft with Microsoft products and get a book or two on command line scripting and learn Unix, BSD and or Linux. You will find that bash schell scriting can interact with MySQL, your environmental variables. read data dump files from any database to spot bad data before you try to upload them to a table and more. Good stuff.

Atreyu167
Atreyu167

chroot is one of my favorite commands

denbo68
denbo68

"...The only disadvantage of Traceroute is that you must have a working network connection to use it." That is sort of like saying the only disadvantage of chkdsk is that you need a disk

hauskins
hauskins

I think this al depends on the user. If you are a sys admin the use of the command line is much easier and faster. ls mv cp truss {f,e,}grep sed vi netstat vmstat etc etc etc

Cicuta2011
Cicuta2011

Question: Do all platforms support TCP/IP? YES!!! There you have more than 20 commands which are irreplaceable. The article should not focus just on Linux but across all UNIX platforms. I can think of at least 50 commands which the SysAdmin really needs on each different platform. What about Windows...well, Windows is not for Enterprise applications really; Windows is OK for desktop applications and checking email at home so forget about Windows. What about the Man pages...the best there is and no GUI can handle that.

mattww3
mattww3

findstr I use this constantly as a quick filter to almost any command being run. finding this command turned some of my batch scripts into valuable tools. I have found that virtually no one knows this command and it is a bit sad. Combined with pstools and a for / f large scale management becomes just a bit easier. net view | findstr -i web will find all servers using wins or net bios with the 'web' as part of the name. type log.txt|findstr -i -c:"My string" here is my favorite use: ##put all hosts that contain the name web in hosts.txt file net view | findstr -i web>>hosts.txt ##starts a new cmd prompt restarting IIS on each host simultaneously for /f %I (hosts.txt) do start iisreset %I .

RMSx32767
RMSx32767

It seems that was so challenging that apps were designed to do that from the GUI.

mamacat
mamacat

Just as aside...I used to have to teach most of my new staff members how to use a computer (yes, I am that old). One of them got the impression that I had invented CD, since that also happens to be my initials. I guess I did not say Change Directory loud enough!

Greg Mix
Greg Mix

This is basically ssh for Windows. I have been using it every day for about 10 years. For installs, I typically provide a UNC path to the target and have it run a script. Also, I often use it just to shell into a machine.

beep54
beep54

While foolishly trying to set up windows 8 on another HDD, I found my USB stick to become unusable. Turned out that somehow the process had rendered it RAW, making it invisible to most of Windows. Diskpart (and I think disklist) was a (really convoluted) method of fixing that.

Editor's Picks