50 interesting Linux command lines
Girish Venkatachalam
Posted on October 14, 2022
- Convert CRLF terminated files to just CR
$ dos2unix file.txt
- Check if JSON is valid
$ json_verify < file.json
- Same as above but prints out nicely.
$ jq < file.json
- Get rid of duplicate spaces occuring together
$ tr -s ' ' < file.txt
- Send mail from command line
$ mutt -s hi foo@yahoo.com < /tmp/mail.txt
- Move in bulk based on patterns
$ mmv -v '*' '#1.jpg'
- Use interactive file deletion DOS style (midnight commander DOS style UI)
$ mc
- Fancy list files (show dirs with /)
$ ls -F
- Show a file with line numbers
$ cat -n file.txt
- Use cut to split fields
$ echo 1:2:3 | cut -d: -f2
- Edit file in place and do search and replace
$ perl -pi -e 's/old/new/' file.txt
- Same as above but not in place
$ sed -e 's/old/new/' file.txt > new.txt
- Spidermonkey (interactive js shell)
$ js
$ node
- Simple video to audio conversion
$ ffmpeg -i file.mp4 song.mp3
- Download youtube video to disk
$ youtube-dl https://youtu.be/XXXX
- Same as above, faster
$ yt-dlp https://youtu.be/XXX
- Show progress bar or ETA with pipeviewer
$ cat file.tgz | pv | tar zxpf
- Play gif animation
$ mplayer file.gif
- View image
$ qiv file.jpg
- Same as above
$ qview file.webp
- Same as above
$ xloadimage file.png
- Same as above
$ display file.png
- Nice PDF viewer
$ mupdf file.pdf
- Fire up a web server using current dir
$ http-server
- Fire up web server to interpret markdown files
$ grip
- Do a simple file upload to FTP or HTTP
$ curl -T file.input ftp://remote/dir/A
- Do a fast download breaking file into chunks and fetch using multiple TCP connections
$ axel <URL>
- Figure out common lines
$ comm file.txt file2.txt
- Compare binary files
$ diff a.bin b.bin
- Printout SHA256 fingerprint
$ openssl dgst sha256 < file.txt
- Same as above.
sha256sum < file.txt
- Always import fresh into git repo
$ find . -name .git | xargs rm -rf
- Hear same song repeatedly
$ mplayer favsong.mp3 -loop 0
- Watch video with vol boost, 0,9 for +,-
$ mplayer -softvol -softvol-max 1000 file.mp4
- Listen to Internet radio on command line
$ mplayer <shoutcast url>
- Resize image with ImageMagick
$ convert file.png -resize 500x500! small.png
- Find out width and height
$ identify favicon.ico
- Tell the length of media
$ mplayer -identify -frames 0 <media>
- Nuke everthing in mp3 after 90 seconds
$ ffmpeg -i file.mp3 -to 90 out.mp3
- Get rid of first 30 seconds.
$ ffmpeg -i file.mp3 -ss 30 out.mp3
- Convert a postscript file to PDF
$ ps2pdf14 file.ps
- Create webp from png or jpg
$ cwebp file.png -o file.webp
- Change image format
$ convert file.jpg file.png
- Copy file.txt to paste buffer
$ cat file.txt| xsel
- Take screenshot from command line
$ import f.png
- Scour entire file system for files
$ locate file
- Look for pattern recursively and ignore case
$ grep -ir pat dir/
- Get rid of newline whilst printing
$ echo -n text
- Batch top output
top -b
- Show speed of download/upload
$ ifstat
💖 💪 🙅 🚩
Girish Venkatachalam
Posted on October 14, 2022
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.
Related
githubcopilot AI Innovations at Microsoft Ignite 2024 What You Need to Know (Part 2)
November 29, 2024