Skip to content

Instantly share code, notes, and snippets.

@mepsrajput
Last active September 12, 2020 15:53
Show Gist options
  • Save mepsrajput/815d12dab68011a10bbc0c31b2200966 to your computer and use it in GitHub Desktop.
Save mepsrajput/815d12dab68011a10bbc0c31b2200966 to your computer and use it in GitHub Desktop.
GCP

sudo (SuperUser DO): run programs / commands with administrative privileges

apt-get

sudo apt-get update The first command you need to run in any Linux system after a fresh install. Updates the database and let your system know if there are newer packages available or not.

sudo apt-get upgrade For upgrading all the packages with available updates.

Or

sudo apt-get upgrade To upgrade a particular package

sudo apt-get install Install a package

dpkg --list List all the packages installed on the system

sudo apt-get remove Remove the package

sudo apt-get purge To remove the software completely with its configuration and/or data files

sudo apt-get autoremove Remove those dependencies that were installed with the earlier installed applications and that are no longer used by anything else on the system.

ls: lists all files and folders in your current working directory.

cd : Change directory cd / : To the root directory. cd .. : Up one directory level. cd – : To the previous directory.

pwd: present working directory

cp: copy cp file1 /home/myfiles will copy the file "file1" to the directory "/home/myfiles"

mv: move mv xyz /home/myfiles

rm: remove

rmdir ("remove directory") - Removes an empty directory. rm -r ("remove recursively") - Removes a directory along with its content.

mkdir: make directory

history: displays history of commands

df: displays filesystem

du: directory usage

free: free space

passwd : change password of a particular user

whatis : info about a command

Ctrl + Shift + T Open new tab on current terminal

Ctrl + Shift + W Close the current tab

Ctrl + A Move cursor to beginning of line

Ctrl + E Move cursor to end of line

Ctrl + U Clears the entire current line

Ctrl + K Clears the command from the cursor right

Ctrl + W Delete the word before the cursor

Ctrl + R Allows you to search your history for commands matching what you have typed

Ctrl + C Kill the current process

Ctrl + Z Suspend the current process by sending the signal SIGSTOP

Ctrl + L Clears the terminal output

Alt + F Move forward one word

Alt + B Move backward one word

Ctrl + Shift + C Copy the highlighted command to the clipboard

Ctrl + Shift + V or Shift + Insert Paste the contents of the clipboard Up/Down Arrow keys To scroll through your command history, allowing you to quickly execute the same command multiple times TAB Used to complete the command you are typing. If more than one command is possible, you can press it multiple times to scroll through the possible completions. If a very wide number of commands are possible, it can output a list of all possible completions.

gcloud auth login - Login to GCloud from the terminal for the first time

Difference B/W Suspending and Stopping an Instance

Suspending an instance differs from stopping an instance in the following ways:

  • Suspended instances preserve the guest OS memory, device state, and application state.
  • Google charges for suspended instances.
  • You can only suspend an instance for up to 60 days. After 60 days, the instance is automatically moved to the TERMINATED state.

With the exception of local SSD data, all resources that are attached to the instance remain attached to the instance and will be charged, including persistent disks and static or reserved external IP addresses.

All of these resources are charged according to the price sheet, even if an instance is suspended.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment