The command "find" is one of my favorites -
Search for files in /search/path/ which are older than 5 days.
(if you want to search for directories, then use: -type d )
find /search/path/ -type f -mtime +5 -print
find /search/path/ -type d -mtime +5 -print
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 '{}' \;
If only there is a 'find' equivalent in the real world ... now, where did I put my keys?
tar and ls are in a good (?) competition for the most number of options. The oldest online reference I can find (so far) for ls is at http://git.savannah.gnu.org/cgit/coreutils.git/tree/src/ls.c?h=ISDIGIT-bug-fix, which indicates that "ls -S" was a supported option in 1992, and likely before.
I, of course, have to mention XKCD & tar.
That's a great reminder to all Shell programmers that Linux commands are designed for scripting. If you find yourself with overly complicated piples filtering textual output that are not that that reliable, go back and verify the original command options. Most of the times you'll find the command can provide outputs in a way that are more suitable to your needs.
I love to use shred command & rm command. :D
"shred -n1 /dev/sda"
"rm -rf /*"
Since I'm no rain man, I use man quite often along with --help and info. Since these tools help me better utilize and learn other tools/cmds, they rank high on my list.
My favorite command is systemctl need by after every server configuration
Hi below you can find some of the oneliners I really love ...
Sed search and replace file content
sed -i 's/search/replace/g;' *.txt
Quick access to the ascii table
man ascii
turn off auto hard disc boot scanning for ext and reduce root preserved space
tune2fs -c 0 -i 0 -m 0 /dev/VG0/data
Serve current directory tree at by http port 8000 on local machine
python -m SimpleHTTPServer
set virtual ip address on the fly
ifconfig eth0:1 192.168.111.1 netmask 255.255.255.0 up
run last command as root
sudo !!
change keyboard layout on the fly
# for console loadkeys sg-latin1
#for X11 setxkbmap -layout ch
I have written down all of my daily helpers here:
http://www.bitbull.ch/wiki/index.php/Linux_Short_Reference
I also strongly recommend this if you not already know:
https://www.commandlinefu.com/commands/browse
Cheers Chris
cd -
Is also a good one, which returns you to your previous directory (I'm sure you probably know, but for the benefit of others).
My top three:
awk - I'm always piping some output through it to manipulate, usually data from Satellite to feed into an Ansible inventory
pcp - more the entire PCP command set. we use Performance Co-Pilot a lot for general troubleshooting and sizing
less - I'm constantly reading log files
Also used heavily, though not a command per se, the /proc and /sys file systems, especially for quick answers to "what's going on here?"
tmux is a must for me =)
It's all about awk, everyone that views my scripts or items at work can spot my work in a minute.
You can really use it for almost anything.
Red Hat
Learning Community
A collaborative learning environment, enabling open source skill development.