Skip to content

Instantly share code, notes, and snippets.

Created December 24, 2017 07:47
Show Gist options
  • Save anonymous/2778701afe96d3ebbca3586a34323bf0 to your computer and use it in GitHub Desktop.
Save anonymous/2778701afe96d3ebbca3586a34323bf0 to your computer and use it in GitHub Desktop.

CLI cheat sheet

My personal cheatsheet for using the Linux command line.


Zip / Unzip

.tar.bz2

tar -jxvf file.tar.bz2

.tar.xz

tar xvfJ file.tar.xz

.tar.gz

tar -zxvf file.tar.gz

.gz

gunzip file.gz

Zip something

zip foo foo.zip

Zip recursively

zip -r file.zip directory/

GIT

Configure GIT

git config --global user.email "user.name@email.ch"
git config --global user.name "Name Surname"

Commit to master

git init
git add README.md
git commit -m "initial commit"
git remote add origin https://github.com/user/repo.git
git push -u origin master

Samba

To add a new Samba user, you first have to create a new Unix user.

sudo useradd --shell /bin/false USER    # new unix user
sudo passwd USER                        # set password
sudo smbpasswd -a USER                  # create samba user

Burning .iso to a USB drive

lsblk -l            #find the usb drive
umount /dev/sdX
dd bs=4MB if=file.iso of=/dev/sdX

SSL

Check for how long your SSL certificate remains valid.

openssl x509 -noout -dates -in /etc/letsencrypt/live/yourdomain.tld/cert.pem

C / C++

Nixcraft: How To Compile And Run a C/C++ Code In Linux

Compile a C++ file

g++ CODE.cpp -o BINARY.exe

Compile a C file

gcc CODE.c -o BINARY.exe

Directory and Files

Size of a directory

du -sh DIR/

Random Filename argument

echo `ls dir | sort -R | tail -n 1`

Installation

sudo dpkg -i pack.deb

Background Process

nohup command > /dev/null 2>&1

Proxy

SSH tunnel

-D [Bind Port]

-p [Remote Port]

ssh -CnN -D 9999 -p 22 user@server.ch # forwards local port 9999 via ssl tunnel

SSH tunnel settings for PuTTY

Connection > SSH > Tunnels :
      Source Port: port
      ☒ Dynamic
      ☒ Auto
      [Add]
Session :
      Host Name: server
      Port: port
      Saved Sessions: name
      [Save]
      [Load]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment