Here’s a quick list of useful Linux lines that Admins should be committing to muscle memory – yeah, Linux guys have muscles, too:
# Watch the file size changes as it's being uploaded
watch -n 1 du -h /var/www/upload/incomingfile.iso
# Run a program (Chrome) in disjointed mode or different shell and return focus to current shell session
exec google-chrome
# Create folder and parent directory in 1 line
mkdir -p ~/grandparent/parent/folder1
# Generate a 100 folders with 1000 files in each one: 100,000 files
touch ~/grandparent/parent/folder{1..100}/{1..1000}.txt
# Exit terminal without killing all child processes
disown -a && exit
# redo last command as root:
sudo !!
# Create RAM disk using memory
mkdir -p /mnt/ram && cd /mnt/ram
mount -t tmpfs tmpfs /mnt/ram -o size=10240M
# Run benchmark of write speed on current disk: use /dev/zero (a Linux empty file generator), filename=benchmark, blocksize 1M, filesize=10240MB
dd if=/dev/zero of=benchmark.file bs=1M count=10240
# Run command without including it in history
[space] COMMAND
# Create a quick tunnel to an obscure port on remote host
ssh -L 2222:127.0.0.1:48684 [email protected] -N
# Access tunnel
ssh -p2222 [email protected]
# Rerun the last exited process in the background
process
ctrl z
bg
# Run process in quiet mode
ls > /dev/null
# Record output of a command while issue Word Count command to return the count of items
ls | tee directoryContents.txt | wc -l
# Elevate while editing a file
:w !sudo tee %
# Run process in the background via '&' marker, no hangup mode. Direct output to 'null' while writing into a log file
nohup processName </dev/null >processName.log 2>&1 &
# Search the logs directory for files with time written in the last minute
find /var/log -type f -mtime +1
# Examining log file
tail -f /var/log/syslog
# Examining large log file - load the end of file first and load only enough for the screen
less +F /var/log/syslog
# multi-threaded traceroute
mtr --curses kimconnect.com
# clear screen
clear
# reinitialize session and reload changed environmental variables without a logout
reset
# open text editor to compose a set of commands that will execute upon exiting text editor
KEYs COMBO: Ctrl x e
# Repeat previous command
KEYs COMBO: alt .
# While typing command, cut everything to the right of cursor
KEYs COMBO: ctrl K
# While typing command, cut everything to the left of cursor
KEYs COMBO: Ctrl U
# Pasting in Shell (Put back what was yanked)
KEYs COMBO: Ctrl Y
# While following file, detach from tailing
KEYs COMBO: Ctrl C
# While detached from tailing, re-attach to tailing
KEYs COMBO: Ctrl F
Categories: