Skip to content

Instantly share code, notes, and snippets.

@BobCHub
Last active February 17, 2018 17:21
Show Gist options
  • Save BobCHub/28e82e12d23fdd992c718f6399f0a828 to your computer and use it in GitHub Desktop.
Save BobCHub/28e82e12d23fdd992c718f6399f0a828 to your computer and use it in GitHub Desktop.
My Linux Snippets
[[snippets]]
description = "! - display all files including hidden"
command = "ls -a"
output = "ls -a"
[[snippets]]
description = "! - display files"
command = "ls"
output = "ls -a"
[[snippets]]
description = "! - Shutdown the system and turn the power off immediately"
command = "shutdown -h now"
output = "shutdown -h now"
[[snippets]]
description = "! - Reboot the system using shutdown command"
command = "shutdown -r now"
output = "shutdown -r now"
[[snippets]]
description = "! - Check the status of ssh service"
command = "service ssh status"
output = "service ssh status"
[[snippets]]
description = "! - Restart ssh service"
command = "service ssh restart"
output = "service ssh restart"
[[snippets]]
description = "! - ssh Create the key pair"
command = "ssh-keygen -t rsa"
output = "ssh-keygen -t rsa"
[[snippets]]
description = "! - Check the status of all the services"
command = "service --status-all"
output = "service --status-all"
[[snippets]]
description = "! - directory containing zsh themes"
command = "cd ~/.oh-my-zsh/themes/"
output = "cd ~/.oh-my-zsh/themes/"
[[snippets]]
description = "! - directory containing zsh plugins"
command = "cd ~/.oh-my-zsh/plugins"
output = "cd ~/.oh-my-zsh/plugins"
[[snippets]]
description = "! - Uptake new changes to .zshrc config file"
command = "source ~/.zshrc"
output = "source ~/.zshrc"
[[snippets]]
description = "! - edit .zshrc file"
command = "vim ~/.zshrc"
output = "vim ~/.zshrc"
[[snippets]]
description = "! - Display RAM usage"
command = "free -h"
output = "free -h"
[[snippets]]
description = "! - display free disk space - human-readable"
command = "df -h"
output = "df -h"
[[snippets]]
description = "! - Central Processing Unit (CPU) statistics and input/output statistics"
command = "iostat"
output = "iostat"
[[snippets]]
description = "! - Updating the package database"
command = "apt-get update"
output = "sudo apt-get update"
[[snippets]]
description = "O - Upgrade all the packages that have updates available"
command = "apt-get upgrade"
output = "sudo apt-get upgrade"
[[snippets]]
description = "! - Upgrade,also intelligently handles changing dependencies with new versions of packages"
command = "apt-get dist-upgrade"
output = "sudo apt-get dist-upgrade"
[[snippets]]
description = "service will automatically start at boot time"
command = "sudo systemctl enable <service_name>"
output = ""
[[snippets]]
description = "! - change password"
command = "passwd"
output = "passwd"
[[snippets]]
description = "! - network - configure, or view the configuration of, a network interface"
command = "ifconfig"
output = "ifconfig"
[[snippets]]
description = "! - show you a complete list of last executed commands with line numbers"
command = "history"
output = "history"
[[snippets]]
description = "! - network - test the reachability of a host on an Internet Protocol IP network"
command = "ping google.com -c 5"
output = "ping google.com -c 5"
[[snippets]]
description = "network - host is a simple utility for performing DNS lookups"
command = "host google.com"
output = ""
[[snippets]]
description = "! - network - find the IP address for the hostname"
command = "hostname -i"
output = "hostname -i"
[[snippets]]
description = "! -network - find out which domain you are on"
command = "hostname -d"
output = "hostname -d"
[[snippets]]
description = "! - network - find computer name"
command = "hostname -s"
output = "hostname -s"
[[snippets]]
description = "! - network - prints the effective user ID"
command = "whoami"
output = "whoami"
[[snippets]]
description = "! - network - display ip address"
command = "ip add"
output = "ip add"
[[snippets]]
description = "! - network - quick way to see who is logged on and what they are doing"
command = "w"
output = "w"
[[snippets]]
description = "! - network - List users currently logged in"
command = "users"
output = "users"
[[snippets]]
description = "! - network - Displays who is logged on to the system"
command = "who -aH"
output = "who -aH"
[[snippets]]
description = "! - network - Show or manipulate the IP routing table"
command = "route -v"
output = "route -v"
[[snippets]]
description = "! - network - prints the route that packets take to a network host"
command = "traceroute google.com"
output = "traceroute google.com"
[[snippets]]
description = "! - network - runs netcat. utility for reading from and writing to network connections using TCP or UDP"
command = "nc"
output = "nc"
[[snippets]]
description = "network - netcat utility can be run in the server mode on a specified port listening for incoming connections"
command = "nc -l 2389"
output = ""
[[snippets]]
description = "network - Listing all the LISTENING Ports of TCP and UDP connections"
command = "netstat -a | more"
output = ""
[[snippets]]
description = "! - network - displays routing table information "
command = "netstat -r"
output = "netstat -r"
[[snippets]]
description = "! - network - stands for name server lookup, is a useful tool for finding out information about a named domain"
command = "nslookup microsoft.com"
output = "nslookup microsoft.com"
[[snippets]]
description = "! - network - configure a wireless network interface.see and set the basic Wi-Fi details like SSID channel and encryption"
command = "iwconfig"
output = "iwconfig"
[[snippets]]
description = "! - network packet analysing tool that is used to display TCP IP & other network packets being transmitted"
command = "tcpdump -D"
output = "tcpdump -D"
[[snippets]]
description = "Shows users belonging to a given group"
command = "lid <userNameHere>"
output = ""
[[snippets]]
description = "Show users in a group"
command = "lid -g <groupNameHere>"
output = ""
[[snippets]]
description = "! - Find user's group memberships"
command = "groups"
output = "groups"
[[snippets]]
description = "creates a new user or sets the default information for new users"
command = "sudo useradd <new_username>"
output = ""
[[snippets]]
description = "remove/delete a user"
command = "sudo userdel <username>"
output = ""
[[snippets]]
description = "delete the home directory for the deleted user account"
command = "sudo rm -r /home/username"
output = ""
[[snippets]]
description = "modify the username of a user"
command = "usermod -l <new_username> <old_username>"
output = ""
[[snippets]]
description = "change the password for a user"
command = "sudo passwd <username>"
output = ""
[[snippets]]
description = "Change the owner of file.txt to user hope"
command = "sudo chown hope file.txt"
output = ""
[[snippets]]
description = "Changes group ownership of a file or files"
command = "chgrp"
output = ""
[[snippets]]
description = "Change the owning group of the file.txt to the group named hope"
command = "chgrp hope file.txt"
output = ""
[[snippets]]
description = "Enables a superuser or root to modify a group"
command = "groupmod"
output = ""
[[snippets]]
description = "groupmod command would change the group newgroup to bettergroup"
command = "groupmod -n bettergroup newgroup"
output = ""
[[snippets]]
description = "! - install ufw - Uncomplicated Firewall"
command = "sudo apt-get install ufw"
output = "sudo apt-get install ufw"
[[snippets]]
description = "! - enable ufw logging"
command = "sudo ufw logging on"
output = "sudo ufw logging on"
[[snippets]]
description = "! - enable ufw firewall"
command = "ufw enable "
output = "ufw enable"
[[snippets]]
description = "groupmod command would change the group newgroup to bettergroup"
command = "ufw limit < > "
output = ""
[[snippets]]
description = "! - modify ufw configuration"
command = "sudo nano /etc/default/ufw"
output = "sudo nano /etc/default/ufw"
[[snippets]]
description = "! - check the status of ufw"
command = "sudo ufw status verbose"
output = "sudo ufw status verbose"
[[snippets]]
description = "! - set your ufw rules back to the defaults - deny incoming"
command = "sudo ufw default deny incoming"
output = "sudo ufw default deny incoming"
[[snippets]]
description = "! - set your ufw rules back to the defaults - allow outgoing"
command = "sudo ufw default allow outgoing"
output = "sudo ufw default allow outgoing"
[[snippets]]
description = "! - configure your server to allow incoming SSH connections"
command = "sudo ufw allow ssh"
output = "sudo ufw allow ssh"
[[snippets]]
description = "write rule by specifying the port"
command = "sudo ufw allow <port>"
output = ""
[[snippets]]
description = "! - enable ufw"
command = "sudo ufw enable"
output = "sudo ufw enable"
[[snippets]]
description = "! - check the status of ufw "
command = "sudo ufw status"
output = "sudo ufw status"
[[snippets]]
description = "! - display ufw rules that are set"
command = "sudo ufw status verbose"
output = "sudo ufw status verbose"
[[snippets]]
description = "! - ufw allow HTTP port 80 connections unencrypted web servers ufw"
command = "sudo ufw allow http"
output = "sudo ufw allow http"
[[snippets]]
description = "! - ufw allow HTTPS port 443 connections - encrypted web servers"
command = "sudo ufw allow https"
output = "sudo ufw allow https"
[[snippets]]
description = "! - ufw allow FTP port 21 connections - unencrypted file transfers which you probably shouldn't use anyway"
command = "sudo ufw allow ftp"
output = "sudo ufw allow ftp"
[[snippets]]
description = "ufw specify port ranges - allow X11 connections, which use ports 6000-6007"
command = "sudo ufw allow 6000:6007/tcp"
output = ""
[[snippets]]
description = "ufw Allow Specific IP Addresses"
command = "sudo ufw allow from <IP address>"
output = ""
[[snippets]]
description = "ufw allow <IP> to connect to port # - note:ssh is port 22"
command = "sudo ufw allow from <IP address> to any port <#>"
output = ""
[[snippets]]
description = "ufw deny all connections from <IP address>"
command = "sudo ufw deny from <IP>"
output = ""
[[snippets]]
description = "! -list of your ufw firewall rules numbered"
command = "sudo ufw status numbered"
output = "sudo ufw status numbered"
[[snippets]]
description = "delete ufw rule by number"
command = "sudo ufw delete <#>"
output = ""
[[snippets]]
description = "delete the specific ufw rule"
command = "sudo ufw delete allow http"
output = ""
[[snippets]]
description = "! - disable ufw"
command = "sudo ufw disable"
output = "sudo ufw disable"
[[snippets]]
description = "! - Reset ufw Rules"
command = "sudo ufw reset"
output = "sudo ufw reset"
[[snippets]]
description = "display ufw rules that are set"
command = "sudo ufw limit proto tcp from <IP address going to> to <IP Address computer your using> port 22 "
output = ""
[[snippets]]
description = "! - start ufw systemd unit"
command = "sudo systemctl start ufw"
output = "sudo systemctl start ufw"
[[snippets]]
description = "! - create .ssh directory for keys"
command = "mkdir ~/.ssh"
output = "mkdir ~/.ssh"
[[snippets]]
description = "! - Make sure your .ssh directory and the files it contains have the correct"
command = "chmod 700 ~/.ssh && chmod 600 ~/.ssh/*"
output = "chmod 700 ~/.ssh && chmod 600 ~/.ssh/*"
[[snippets]]
description = "! - Install the open ssh-server application and client"
command = "sudo apt-get install openssh-client"
output = "sudo apt-get install openssh-client"
[[snippets]]
description = "! - confirm ssh server process running on your machine - should see - [number] ? 00:00:00 sshd"
command = "ps -A | grep sshd"
output = "ps -A | grep sshd"
[[snippets]]
description = "! - generate the ssh key - step 1 on the server"
command = "ssh-keygen -t rsa"
output = "ssh-keygen -t rsa"
[[snippets]]
description = "copy the public key from the server to the client"
command = "ssh-copy-id -i ~/.ssh/id_rsa.pub <USER>@<IP Address>"
output = ""
[[snippets]]
description = "! - configure secure shell ssh config file - Set - PasswordAuthentication no"
command = "vim /etc/ssh/sshd_config"
output = "vim /etc/ssh/sshd_config"
[[snippets]]
description = "! - restart ssh service"
command = "sudo service ssh restart"
output = "sudo service ssh restart"
[[snippets]]
description = "! - install samba Common Internet File System"
command = "sudo apt-get install samba"
output = "sudo apt-get install samba"
[[snippets]]
description = "! - change a user's samba password"
command = "smbpasswd "
output = "smbpasswd"
[[snippets]]
description = "! - enable ufw systemd unit"
command = "testparm"
output = "testparm"
[[snippets]]
description = "! - Create shared samba folder called “shared folder"
command = "sudo mkdir -p /srv/samba/sharedfolder"
output = "sudo mkdir -p /srv/samba/sharedfolder"
[[snippets]]
description = "! - samba Allow anyone to access and store files in folder"
command = "sudo chown nobody:nogroup /srv/samba/sharedfolder/"
output = "sudo chown nobody:nogroup /srv/samba/sharedfolder/"
[[snippets]]
description = "! - Make a backup of the samba configuration file before editing"
command = "sudo cp /etc/samba/smb.conf /etc/samba/smb.conf.old"
output = "sudo cp /etc/samba/smb.conf /etc/samba/smb.conf.old"
[[snippets]]
description = "! - Open the samba conf file and make the following changes to end of the file - d. Restart smbd service -"
command = "sudo vim /etc/samba/smb.conf"
output = "sudo vim /etc/samba/smb.conf"
[[snippets]]
description = "! - Restart samba service"
command = "sudo systemctl restart smbd.service nmbd.service"
output = "sudo systemctl restart smbd.service nmbd.service"
[[snippets]]
description = "! - Create samba shared folder called “securedfolder” "
command = "sudo mkdir -p /srv/samba/securedfolder"
output = "sudo mkdir -p /srv/samba/securedfolder"
[[snippets]]
description = "! - samba secure - Create a new secure user group named “selected” "
command = "sudo addgroup selected"
output = "sudo addgroup selected"
[[snippets]]
description = "! - samba secure - Modify permission and ownership for the folder"
command = "sudo chown root:selected /srv/samba/securedfolder/ && sudo chmod 770 /srv/samba/securedfolder/"
output = "sudo chown root:selected /srv/samba/securedfolder/ && sudo chmod 770 /srv/samba/securedfolder/"
[[snippets]]
description = "samba secure - Make a backup of the configuration file before editing - Add the following at the end of the samab config file to enable sharing - [sharedfolder] comment = secured shared folder path = /srv/samba/securedfolder Valid users = @selected guest ok = no writable = yes browsable = yes....Then restart and testparm"
command = "sudo vim /etc/samba/smb.conf"
output = ""
[[snippets]]
description = "! - install the ntp Network Time Protocol daemon"
command = "sudo apt-get install ntp"
output = "sudo apt-get install ntp"
[[snippets]]
description = "! - Configure the ntp Network Time Protocol Servers - server tick.gov.bc.ca iburst - server tock.gov.bc.ca iburst"
command = "sudo vim /etc/ntp.conf"
output = "sudo vim /etc/ntp.conf"
[[snippets]]
description = "! - restart ntp Network Time Protocol Server"
command = "sudo service ntp restart"
output = "sudo service ntp restart"
[[snippets]]
description = "! - restart ntp Network Time Protocol Server"
command = "sudo service ntp restart"
output = "sudo service ntp restart"
[[snippets]]
description = "! - update ntp Network Time Protocol Server"
command = "sudo /etc/init.d/ntp restart"
output = "sudo /etc/init.d/ntp restart"
[[snippets]]
description = "! - Edit web server page"
command = "vim /var/www/html"
output = "vim /var/www/html"
[[snippets]]
description = "! - edit sysctl config file - set advanced security options"
command = "vim /etc/sysctl.config"
output = "vim /etc/sysctl.config"
[[snippets]]
description = "! - edit bash config file - add aliases ie - alias rm=‘rm -l’ "
command = "vim ~/.bashrc"
output = "vim ~/.bashrc"
[[snippets]]
description = "! - lists all open files belonging to all active process on the system"
command = "lsof -i -P "
output = "lsof -i -P "
[[snippets]]
description = "! - Lists the status of all running jobs - jobs displays process ID"
command = "jobs"
output = "jobs"
[[snippets]]
description = "! - The kill command sends a signal to a process- Terminate process(es)"
command = "kill %<proccess id> "
output = ""
[[snippets]]
description = "! - Reports a snapshot of the status of currently running process(es)"
command = "ps axu"
output = "ps axu"
[[snippets]]
description = "! - pstree displays process(es) in tree format"
command = "pstree -h"
output = "pstree -h"
[[snippets]]
description = "! - List process(es) running on the system"
command = "top "
output = "top"
[[snippets]]
description = "! - List process(es) running on the system"
command = "htop"
output = "htop"
[[snippets]]
description = "! - job control command that resumes suspended jobs while keeping them running in the background - press Control-Z and the job will stop"
command = "bg"
output = "bg "
[[snippets]]
description = "! - The stopped job will resume operation, but remain in the background"
command = "bg %<job #>"
output = ""
[[snippets]]
description = "! - Resume the specified job in the foreground, and make it the current job"
command = "fg %<job #>"
output = ""
[[snippets]]
description = "! - history - show you a complete list of last executed commands with line numbers"
command = "history"
output = "history"
[[snippets]]
description = "history - Executes the most recently executed command that begins with the letters ls"
command = "!ls"
output = ""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment