Home

Useful Terminal Commands

1 MIN READ
Post cover image

Table of contents

whois

Get Information for a Domain Name

whois google.com

hostinfo

Get information about system hardware, kernel, processors and memory.

hostinfo

alias

Create a shortcut for a command or multiple commands

alias mfs="php artisan migrate:fresh --seed"

mfs  # runs php artisan migrate:fresh --seed

host

Get IP Address / DNS records for a given domain name

host github.com

# Returns nameservers for domain
host -t ns google.com

compgen

List all commands that could be run on the system

compgen -c

Pipe output through grep to find a specific command

compgen -c | grep searchTerm

List builtin commands

command -b

less

Read a file - can move up and down through file

less index.js

Can use j and k to traverse up and down the file.

head & tail

head file.js	# Gets first 10 lines of file
tail file.js	# Gets last 10 lines of file

tar

Create compressed archive files.

# Command structure
tar -czf [compressedFileName] [directoryToCompress]

tar -czf compressed.tar.gz folder/

The -c flag creates a new archive, -z uses gzip compression and -f specifies archive file

lsof

List what process is running on a specific port

lsof -i :3000

df

Show free disk space information

df -h  # -h flag formats file sizes in human readable format

printenv

Print environment variables

printenv

grep

Search a given input file

less file.txt | grep searchTerm

The grep command is often used in conjunction with piping - sending an output of a command as an input to another.

man

Show manual pages for a command

man chmod

The output of the man command is shown in a vim-like editor. You can use j, k and other vim shortcuts to traverse the output.

Back to Home