Avatar
This is a hunble programmer here. I like to make cool websites, do coding for fun, automate my tasks using scripts and also collect useful information on my notes App called Joplin. So whatever i learned or found I like to share them in form of blogs too.

Awesome Classic cli tools

These were invented way back and is inbuilt most of time. They provide stability. Many of you know so my goal is to appreciate them. This list may not be seem that exciting and maybe boring because they dont do anything interesting but they are vital.

Contents

  1. Basic unix tools
  2. git
  3. screen
  4. sed
  5. ffmpeg
  6. curl
  7. wget
  8. find
  9. rsync
  10. ssh
  11. top
  12. tar and gzip

 

Basic unix tools

Some basic unix tools like ls, cd, grep,nano,vim, cat, etc. These are inbuilt tools and lays the foundations of unix. ls is used to list contents of directory. cd is used to navigate to particular directory.

Grep is a useful command to search for matching patterns in a file. grep is short for “global regular expression print”. Its usage: history | grep "cd". history command will output all the commands used previously and this output will be piped to grep which will search for the word ‘cd’ and if those lines contain that word then that line will be printed.

nano and vim are TUI text editors so useful for editing a text file quickly in terminal and cat is used to read, display, and concatenate text files.

usage:

 

Git

Git is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency. It is wonderful version control system developed by Linus Torwalds(creator of linux). Without it, I have to create separate backups before changing some things and would be pain too.

Usage

Some common git commands are git add ., git commit -m 'commit message', git status, git push, git pull, git log. Refer to this cheatsheet for more git commands https://linuxcommandlibrary.com/basic/git

Source code

https://git.kernel.org/pub/scm/git/git.git/

 

Screen

It is a terminal multiplexer: a software application that can be used to multiplex several virtual consoles. When we login through some ssh terminal we only get one screen or if we dont have GUI and is only limited to few tty then this is where this comes in. Using this we can have multiple sessions, windows allowing someone to have multiple commands or services running and provides a way for multitasking.

Source code

https://git.savannah.gnu.org/cgit/screen.git

 

Sed

It stands for stream editor. It parses and transform text. It does all this on input stream so it can be a input from a pipeline or file too. It is also used with awk too

Usage

file.txt

apple, 5, 0.99
banana, 10, 0.59
cherry, 7, 1.29

sed 's/, */,/g' file.txt | awk -F ',' '{print $1 " costs " $2 * $3}' This will remove commas from file

For more information regarding this refer to this guide https://www.baeldung.com/linux/grep-sed-awk-differences

Source code

https://git.savannah.gnu.org/git/sed.git/

Tldr

 

ffmpeg

FFmpeg is a collection of libraries and tools to process multimedia content such as audio, video, subtitles and related metadata. It is impressive software and is core of many softwares like Blender,Handbrake, Shotcut, VLC and video hosting platforms like Youtube. Also it is used by the Perseverance rover on Mars for image and video compression before footage is sent to Earth.

Usage There are lot of commands but few important one that i personally use are as follows.

# converting all videos of current folder to  audio
for arg in * ; do
   ffmpeg -i "${arg}" -vn  "${arg%%.*}.mp3"
done

# extracting particular section of video and also encode it too to h264 with ac3(most widely supported surround sound codec)
ffmpeg -i inputVideo.mkv -ss 00:35:18.00 -t 50 -c:v libx264 -c:a ac3 -crf 20 -map 0:v:0 -map 0:a:1 recorded1.mp4
# -map 0:v:0 means 1st video track
# -map 0:a:1 means 2nd audio track

Source code

https://git.ffmpeg.org/ffmpeg.git

 

curl

curl is a command-line tool (curl) for transferring data using various network protocols. The name stands for “Client for URL”. It is powered by the library libcurl. It is very useful for testing api, getting metadata,data of site,etc. Many linux users who install softwares might have used like this curl -sSL https://raw.githubusercontent.com/AdguardTeam/AdGuardHome/master/scripts/install.sh | sh . This will get the script and then piped to sh and sh will execute it.

Source code

https://github.com/curl/curl

 

wget

This command is used to download files from remote resource. So if we are in a server and we wanna download some file we can just do that by using direct downloadable link. wget may seem like curl command but wget is made specific for this purpose. Also, wget’s major strong side compared to curl is its ability to download recursively.

Usage

# download file from the link and save it to file with name 'w3m.tar.xz'
wget -O w3m.tar.xz https://archive.archlinux.org/packages/w/w3m/w3m-0.5.3.git20190105-1-x86_64.pkg.tar.xz

Source code

https://git.savannah.gnu.org/cgit/wget.git

 

find

It is a utility that locates files based on some user-specified criteria and either prints the pathname of each matched object or, if another action is requested, performs that action on each matched object. It can search recursively too.

Usage

# this will find all files and directories that contain rclone as a word starting from home directory
# and will find recursively
find ~ -name '*rclone*'

# this will find all files that contain word pattern or contains a folder named 'path' in its full path with extension 'ext'
# and will find recursively
find root_path -regex '.*/path/.*\.ext$' -or -name '*pattern*'

Source code

https://git.savannah.gnu.org/cgit/findutils.git

 

rsync

It is a utility that provides fast incremental file transfer. Also useful for backup, restore and synchronize data too. Sometimes we may wanna sync files to some other device while also preserving their metadata too, this is where rsync comes in. It is a powerful tool and I use it to sync my files across my mobile and PC by combining it with cron job.

Usage

rsync -avz --delete "$SOURCE/" "$DESTINATION/"

Source code

https://github.com/RsyncProject/rsync

 

ssh

The Secure Shell Protocol (SSH Protocol) is a cryptographic network protocol for operating network services securely over an unsecured network. Very useful for remote login and executing commands. Server must have openssh installed though and sshd running in background. ssh uses public key cryptography for secure connection. It can be also used for port forwarding when port forwarding is not allowed on particular network so user can use reverse tunelling too and connect to vps.

To know more about it refer to this https://www.cloudflare.com/learning/access-management/what-is-ssh/.

Usage

# connecting to server having ip address 192.168.16.91 and username 'buser' to port 22
ssh buser@192.168.16.91 -p 22

Source code

https://github.com/openssh/openssh-portable

 

top

top (table of processes) is a task manager or system monitor program, found in many Unix-like operating systems, that displays information about CPU and memory utilization. GNU/Linux is a multi-tasking OS so it means many processes can run and they run in background too in form of daemon so it is necessary to monitor those processes. It is true that today we have htop,btop and many other but this is the origianal ones.

Source code

https://gitlab.com/procps-ng/procps

 

Tar and Gzip

It is a utility for collecting many files into one archive file, often referred to as a tarball, for distribution or backup purposes. After files are bundled in .tar then using gzip it can be compressed into .tar.gz.

Usage

# create an archive and write it to a [f]ile
tar cf path/to/target.tar path/to/file1 path/to/file2

# compresses a file while also keeping original one
gzip --keep path/to/file

Source code

https://git.savannah.gnu.org/cgit/tar.git/ and https://git.savannah.gnu.org/cgit/gzip.git/

all tags