BramMertens
Mission Specialist
Mission Specialist
  • 2,157 Views

Re: What's your favorite tool/cmd in Linux?

Another great tool to use that is often overlooked is xargs.

Combined with find, ls, echo, grep etc. you can achieve powerfull combinations.

The more I learn to use vim the more I'm impressed by what it can do.

On the fly recorded macro's have helped me several times to generate or update large number of complex (SQL) statements etc.

It's built in powerful search and replace has prevented countless hours of tedious work.

And a third huge time saver that surprisingly many people are unfamiliar with is ssh-agent. Being able to easily and securly log on to many machines is a great time saver as well.

RHCE 100-015-239
0 Kudos
Reply
Loading...
csaunderson
Cadet
Cadet
  • 2,138 Views

Re: What's your favorite tool/cmd in Linux?

lsof. So much lsof. So useful for tracing back a port that's in use to a running process, and then for diagnosing beyond that.

0 Kudos
Reply
Loading...
Lars
Flight Engineer Flight Engineer
Flight Engineer
  • 2,149 Views

Re: What's your favorite tool/cmd in Linux?

One of the most important cmd especially when you're working remote is tmux!

0 Kudos
Reply
Loading...
AngelReynoso
Mission Specialist
Mission Specialist
  • 2,144 Views

Re: What's your favorite tool/cmd in Linux?

I like all the Linux tools .

Reply
Loading...
Jeff_Schaller
Flight Engineer
Flight Engineer
  • 2,130 Views

Re: What's your favorite tool/cmd in Linux?

I'd follow on to the


@kubeadm wrote:

If you want to do something with those files after you've found them, use:  -exec <somecmd> '{}' \; 

Example, delete files older than 50 days in the /search/path directory

find /search/path/ -type f -mtime +50 -exec rm '{}' \;

 

example by suggesting two enhancements:

1. Use -delete for the specific case of removing files or directories; it saves having to call out to another program just to delete something. It was added in 2004 , so hopefully (!) it's on the majority of systems you're working on. It also "does the right thing" by turning on -depth mode, so you don't end up trying to remove a directory before it's empty.
2. Use "-exec command {} +" for the more general case of executing a command against multiple files. Introduced in 2005 , this is useful for any command (such as rm) that accepts multiple files as parameters to work on. It's similar to xargs, but avoids the problems with passing filenames through a pipe.

Reply
Loading...
Jeff_Schaller
Flight Engineer
Flight Engineer
  • 2,132 Views

Re: What's your favorite tool/cmd in Linux?

I'd have a hard time choosing a favorite; the most frequent are boring (ls, cd) or opinionated (vi/vim), and there are powerful candidates like ps, grep, awk, etc; but I'll propose "sudo" as my favorite. It enables fine-grained elevated permissions and I enjoy using it as a sysadmin just to keep my normal prompt un-elevated (in case of accidents!) and to log what I (and other) sysadmins type, again, usually to investigate an accident.  But mainly to limit the potential damage when a non-sysadmin needs to do a few specific things with elevated privileges.

0 Kudos
Reply
Loading...
Vinícius_Boas
Flight Engineer Flight Engineer
Flight Engineer
  • 2,125 Views

Re: What's your favorite tool/cmd in Linux?

awk/gawk ... Everything is possible with awk/gawk + shell script! Smiley Happy

 

In Red Hat I trust, everything else, I test!
Reply
Loading...
  • 2,120 Views

Re: What's your favorite tool/cmd in Linux?

I have a couple of favorites that have become standard aliases on any system I use regularly:

  alias top10=' ls -la | sort -rn -k 5 | head '
  alias topdu=' du -sk .[0-9A-Za-z]* [0-9A-Za-z]* 2>/dev/null | sort -rn | head '

"top10" lists the 10 biggest files in the current directory, and "topdu" shows the 10 subdirectories under the current directory that are taking up the most space.  In either case you can add "-#" to change the number of lines output.  For example "top10 -20" shows the 20 biggest files.

 

0 Kudos
Reply
Loading...
Jeff_Schaller
Flight Engineer
Flight Engineer
  • 2,114 Views

Re: What's your favorite tool/cmd in Linux?

@Gordon-Keegan, if you work exclusively on RedHat systems -- or, I should say, GNU/Linux systems with GNU coreutils' ls, then you may be interested in:

alias top10='ls -laS | head '

as that will instruct "ls" to do the sorting by size, versus having to rely on field 5 being the size. Consider a system that's integrated with LDAP or Active Directory and a user's primary group name contains spaces.

Reference: ls invocation -- 10.1.3 Sorting the output

Reply
Loading...
  • 2,108 Views

Re: What's your favorite tool/cmd in Linux?

TIL ! Thanks for the tip, it's apparently been too long since I reviewed the cmdline args Smiley Happy   Hmmm...   That means I should probably review other commands.

0 Kudos
Reply
Loading...
Join the discussion
You must log in to join this conversation.