Useful linux command line tools - Part1
Cheat
cheat allows you to create and view interactive cheat sheets on the command line.
Installation
cd /tmp \
&& wget https://github.com/cheat/cheat/releases/download/4.4.0/cheat-linux-amd64.gz \
&& gunzip cheat-linux-amd64.gz \
&& chmod +x cheat-linux-amd64 \
&& sudo mv cheat-linux-amd64 /usr/local/bin/cheat
Example
$ cheat ls
# To display everything in <dir>, excluding hidden files:
ls <dir>
# To display everything in <dir>, including hidden files:
ls -a <dir>
# To display all files, along with the size (with unit suffixes) and timestamp:
ls -lh <dir>
# To display files, sorted by size:
ls -S <dir>
# To display directories only:
ls -d */ <dir>
# To display directories only, include hidden:
ls -d .*/ */ <dir>
# To display all files sorted by changed date, most recent first:
ls -ltc
# To display files sorted by create time:
ls -lt
# To display files in a single column:
ls -1
# To show ACLs (MacOS):
# see also `cheat chmod` for `/bin/chmod` options for ACLs
/bin/ls -le
# To show all the subtree files (Recursive Mode):
ls -R
bat
bat A cat(1) clone with wings. It provides following features:
- Syntax highlighting
- Git integration
- Show non-printable characters
- Automatic paging
- File concatenation
Installation
sudo apt install bat
mkdir -p ~/.local/bin
ln -s /usr/bin/batcat ~/.local/bin/bat
Example
Display a single file on the terminal:
bat <file>
Display multiple files at once:
bat <file> <file>
Show and highlight non-printable characters:
bat -A <file>
Display all supported languages:
bat --list-languages
fd
fd A simple, fast and user-friendly alternative to 'find'.
Installation
sudo apt install fd-find
ln -s $(which fdfind) ~/.local/bin/fd
Example
Find files and directories in the current directory recursively
fd
Find files and directories containing app
fd app
Find only files containing app
fd app --type f
Find only directories containing app
fd app --type d
Find all md files
fd -e md
Find all md files containing readme
fd -e md readme
Find files with exactly the provided search pattern
fd -g libc.so /usr
Recursively find all zip archives and unpack them:
fd -e zip -x unzip
Convert all _.jpg files to _.png files:
fd -e jpg -x convert {} {.}.png
exa
exa is a modern replacement for ls. It provides following features:
- Colours: The list of file types and how to tell files apart.
- Grid view: Displaying files in a grid sized to the terminal window.
- Long view: Displaying files in a table along with their metadata.
- Tree view: Displaying files in a tree, as well as their children.
- Git integration: Seeing the Git status of files when you’re inside a repository.
- Filtering: Hiding files from the list, showing invisible files, and sorting the output.
- Icons: Using Unicode characters to display icons next to file names.
- xattrs: Listing files’ extended attributes.
Installation
apt install exa
Example
Tree view
$ exa --tree --level=2 rust/rust-ansi-parse
rust/rust-ansi-parse
├── bin
│ └── parse-ansi-codes.rs
├── Cargo.lock
├── Cargo.toml
├── README.md
├── src
│ ├── cursor.rs
│ ├── lib.rs
│ └── style.rs
├── target
│ └── debug
└── test
Tree view combined with long veiw
$ exa --tree --level=2 rust/rust-ansi-parse --long
drwxr-xr-x - ben 8 Dec 9:03 rust/rust-ansi-parse
drwxr-xr-x - ben 8 Dec 9:09 ├── bin
.rw-r--r--@ 0 ben 8 Dec 9:09 │ └── parse-ansi-codes.rs
.rw-r--r-- 764 ben 8 Dec 9:03 ├── Cargo.lock
.rw-r--r--@ 195 ben 8 Dec 9:12 ├── Cargo.toml
.rw-r--r-- 109 ben 7 Dec 21:56 ├── README.md
drwxr-xr-x - ben 7 Dec 22:45 ├── src
.rw-r--r--@ 459 ben 8 Dec 9:13 │ ├── cursor.rs
.rw-r--r--@ 405 ben 8 Dec 9:14 │ ├── lib.rs
.rw-r--r--@ 562 ben 7 Dec 23:09 │ └── style.rs
drwxr-xr-x - ben 8 Dec 9:03 ├── target
drwxr-xr-x@ - ben 8 Dec 9:04 │ └── debug
drwxr-xr-x - ben 7 Dec 21:58 └── test
Git integration
$ git status
modified: icon.scss
Untracked files:
plain-link.scss
$ exa --long --git
Permissions Size User Date Modified Git Name
.rw-r--r-- 260 ben 23 Nov 17:47 -M icon.scss
.rw-r--r-- 612 ben 23 Nov 17:47 -- media.scss
.rw-r--r-- 59 ben 25 Nov 17:23 -N plain-link.scss
.rw-r--r-- 155 ben 23 Nov 17:47 -- unselectable.scss
Ignoring by pattern
$ exa
Alphabetize.scpt Open URL.scpt Select Line.scpt Word Count.scpt
Lowercase.scpt rot13.sh Uppercase.scpt
$ exa --ignore-glob="*case*"
Alphabetize.scpt Open URL.scpt rot13.sh Select Line.scpt Word Count.scpt
Show hidden files
exa --all
Sorting the output
exa --sort=name
exa --sort=size
exa --sort=ext
Deb-get
deb-get provides apt-get functionality for .debs published in 3rd party repositories or via direct download
Installation
curl -sL https://raw.githubusercontent.com/wimpysworld/deb-get/main/deb-get | sudo -E bash -s install deb-get
Example
deb-get install du-dust
du-dust
du-dust is a more intuitive version of du in rust
Installation
deb-get install du-dust
Example
