Skip to content

Instantly share code, notes, and snippets.

@hutgrabber
Created March 6, 2024 12:17
Show Gist options
  • Save hutgrabber/bf680506b77b6746f30a988254632a85 to your computer and use it in GitHub Desktop.
Save hutgrabber/bf680506b77b6746f30a988254632a85 to your computer and use it in GitHub Desktop.
Linux Commands - Nibber

Linux Commands


Miscellaneous → quality of life improvements for CLI.

#chmod---------------------
chmod [r, u, g] [file] #basic syntax
chmod 444 file_name.type #example
chmod [+r, +w, +x] file_name.type #using literals
chmod
#remove---------------------
rm -rf [file] #basic syntax
#list---------------------
ls #list content of current directory
ls /path/to/file # list content of another directory
ls -l # view list with metadata (no hidden files)
ls -la # view list with metadata (with hidden files)
#users---------------------
su #switch users
sudo #super user do
sudo su #switch user to root
whoami #show current user
#alias---------------------
alias #lists all aliases
alias [option] [name] = '[value]' #create a temp alias
unalias [name] # deletes a temp alias
unalias -a # removes all alises
alias move ='mv -i' #example
alias action ='path/to/script/action_script.sh' #running a script with an alias
#create a permenant alias
sudo nano ~/.zshrc #step_1 edit the file
source ~/.zshrc #step_2 compile the changes

Grep → different things that grep can do (pretty long).

#basic syntax
grep "text"

#recursive scan
grep -R <whatever>

Find → everything that find can do. Sit tight!

#basic syntax
find [directory] -name "text"
find [directory] -iname "text" #ignore case

Networking → dump of different networking commands in linux.

ifconfig -a #all network configurations
ping6 #ping via IPv6 address

gzip → zip and unzip files.

gzip file_name.type #compress
gzip -d file_name.type #decompress
gzip -k file_name.type #keep original file
gzip -dk file_name.type #decompress & keep original

zip → zip and unzip files recursively.

zip -r file_name.zip 'directory to zip' #zip files recursively
zip -r lect.zip 'Lecture Programs/' #example

SCP (Secure Copy Protocol) → used to send files to a remote machine through CLI.

scp file.type [user]@[ipaddr]:/path/to/file

SSH (Secure Shell) → connect to a remote machine.

ssh -i "keyFile.pem" [user]@[ipaddr] #any remote machine
ssh -i "testKey.pem" [email protected] #example

python3 → starting a server.

python3 -m http.server [port]
python3 -m http.server 80 #example

Curl → uploading & downloading files to & from internet serves (supports many services HTTP, FTP, IMAP, POP3, SCP, SFTP, SMTP, TFTP, TELNET, LDAP, or FILE).

curl [options] [URL...] # syntax
curl https://www.geeksforgeeks.org # example
curl http://site.{one, two, three}.com # can do multiple domains
curl ftp://ftp.example.com/file[1-20].jpeg # ftp servers
curl -'#' -O ftp://ftp.example.com/file.zip # progress bar (skip the quotes on the hash)
curl --silent ftp://ftp.example.com/file.zip # for a silent transfer
curl -o file_name.zip ftp://website.name.net/file_name.zip # downloads the file with the name given in the -o option
curl -u {username}:{password} [FTP_URL] # working with authenticated ftp servers
curl -u {username}:{password} -T {filename} {FTP_Location} # uploading a file to the ftp
curl dict://dict.org/d:{word_to_search} # get word-meanings in the command line

Wget → download files from the server even when the user is not logged in. Supports all the protocols that curl does.

wget [option] [URL] # syntax
wget http://example.com/sample.php # download the webpage
wget -b http://www.example.com/samplepage.php # -b dnld in the bckgrnd
wget --tries=10 http://example.com/samplefile.tar.gz # try a given number of times
wget -i file_name.txt # list the urls in the inputfile
wget -w [seconds] [URL] # wait between dnlds
wget -r [URL] # recursive downld
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment