Skip to content

Instantly share code, notes, and snippets.

@l3lake
Last active December 25, 2017 14:08
Show Gist options
  • Save l3lake/ee34e4b37db4299a9a70 to your computer and use it in GitHub Desktop.
Save l3lake/ee34e4b37db4299a9a70 to your computer and use it in GitHub Desktop.
My Ubuntu cheat sheet

Ubuntu Cheat Sheet

TOC

Bash Stuff

From: http://cli.learncodethehardway.org/bash_cheat_sheet.pdf

Basic Terminal Shortcuts

CTRL L = Clear the terminal

CTRL D = Logout (less, more)

SHIFT Page Up/Down = Go up/down the terminal

CTRL A = Cursor to start of line

CTRL E = Cursor the end of line

CTRL U = Delete left of the cursor tail = from the bottom

CTRL K = Delete right of the cursor -n <#oflines>

CTRL W = Delete word on the left

CTRL Y = Paste (after CTRL U,K or W) mkdir = create new folder

TAB = auto completion of file or command mkdir myStuff ..

CTRL R = reverse search history mkdir myStuff/pictures/ ..

!! = repeat last command

CTRL Z = stops the current command (resume with fg in foreground or bg in background)

Basic file manipulation

cat <fileName> = show content of file

head = from the top

head -n <#oflines> <fileName> = from the top #oflines

List all services

sudo service --status-all

Change folder/file ACCESS group

chgrp www-data filename

Get a list of packages installed locally

dpkg --get-selections | grep -v deinstall

List out only listening connections

netstat -tnl

From http://www.binarytides.com/linux-netstat-command-examples/

Port Scanner at http://en.dnstools.ch/port-scan.html

Get rid of persistent update message upon login

From http://ubuntuforums.org/archive/index.php/t-1222909.html

Looks like:

36 packages can be updated.

14 updates are security updates.

sudo apt-get dist-upgrad

sudo reboot

Add, Delete, Modify Users

From http://askubuntu.com/questions/410244/a-command-to-list-all-users-and-how-to-add-delete-modify-users

Add user:

sudo adduser username

Delete user:

sudo deluser username

Delete the users home directory:

sudo rm -r /home/username

Modify the username of a user:

sudo usermod -1 new_username old_username

Change the password of a user:

sudo passwd username

Change the shell for a user

sudo chsh username

Change details for a user:

sudo chfn username

Give sudo permissions to user:

sudo usermod -a -G sudo username

To see a list of all users

sudo cut -d: -f1 /etc/passwd

Add ssh keys to user

From https://www.digitalocean.com/community/tutorials/how-to-set-up-ssh-keys--2

  1. create new user and give sudo permissions [above]
  2. create .ssh directory in user's home folder as user
  3. add a authorized_keys file to .ssh/
  4. copy the public keys into authorized_keys file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment