Common Commands Cheat Sheet by Mmorykan Via Cheatography.Com/89673/Cs/20411

Common Commands Cheat Sheet by Mmorykan Via Cheatography.Com/89673/Cs/20411

Common Commands Cheat Sheet by mmorykan via cheatography.com/89673/cs/20411/ Scripting Scripting (cont) GitHub bash filename - Runs script sleep value - Forces the script to wait value git clone <url​ > - Clones gitkeeper url Shebang - "#​ !bi​ n/b​ ash​ " - First line of bash seconds git add <fil​ ena​ me>​ - Adds the file to git script. Tells script what binary to use while [[ condition ]]; do stuff; done git commit - Commits all files to git ./file​ name - Also runs script if [[ condition ]]; do stuff; fi git push - Pushes all git files to host # - Creates a comment until [[ condition ]]; do stuff; done echo ${varia​ ble} - Prints variable words="​ h​ ouse dogs telephone dog" - Package / Networking hello_int = 1 - Treats "1​ " as a string Declares words array dnf upgrade - Updates system packages Use UPPERC​ ASE for constant variables for word in ${words} - traverses each dnf install - Installs package element in array Use lowerc​ ase​ _wi​ th_​ und​ ers​ cores for dnf search - Searches for package for counter in {1..10} - Loops 10 times regular variables dnf remove - Removes package for ((;;)) - Is infinite for loop echo $(( ${hello​ _int} + 1 )) - Treats hello_int systemctl start - Starts systemd service as an integer and prints 2 break - exits loop body systemctl stop - Stops systemd service mktemp - Creates temporary random file for ((count​ er=1; counter -le 10; counter​ ++)) systemctl restart - Restarts systemd service test - Denoted by "[[ condition ]]" tests the - Loops 10 times systemctl reload - Reloads systemd service condition ${arra​ y[I]} - Indexes array configu​ ration files bash -x - Prints commands and their ${arra​ y[]} - References the whole array. systemctl enable - Enable systemd service arguments Can also use @* at boot ps -f - Copies the current shell in the fork declare -A array - declares associa​ tive systemctl disable - Disable systemd service exit value - Exits the script with value exit array systemctl status - Displays activity state code myassoc​ arr​ ay=​ ([a​ ppl​ e]=​ "red​ " [banana​ ]="​ ‐​ and some log lines of service -n varia​ ble - decides if variable is not yell​ ow"​ ) - Creates associa​ tive array atq - Displays currently scheduled empty ${myas​ soc​ arr​ ay[​ ban​ ana]} - References commands -z varia​ ble - Decides if variable is empty bananas value in the array at - Runs command once at certain unset array[I] - Deletes the I index $? - Stands for the previous exit code time/day unset array - Deletes the array $# - Stands for the number of arguments atrm - Remove scheduled commands passed ${#arr​ ay} - Outputs the length of the array crontab -e - Create a file for scheduled [[ $# -ne 2 ]] - Evaluates to true if the alias ll = 'ls -l' - Creates the ll command as commands to run number of arguments is not equal to 2 an alias journa​ lctl - Shows logs -f filen​ ame - Determines if filen​ ame is a file home() { do stuff ; } Creates the home dmesg - Shows kernel messages, function -d direc​ tor​ yNa​ me - Determines if direc​ to‐​ hardware, driver, etc. ryNa​ me is a directory return - defaults to the previous exit value history - Shows previous commands $1, $2, $3 - Refers to the first, second, and local - Creates local variable within function script - Records all input and writes it to a third arguments cut - Cuts away parts of the output file -eq - means == route - Configures IP connection -lt - Means < hostname - Sets system host name -le - Means <= netstat -rn - Gives routing table -gt - Means > ifconfig - Outputs network interface -ge - Means >= ip addr - Shows different addresses and dirname - Prints directory name of of internet connect​ ions argument By mmorykan Published 18th December, 2019. Sponsored by CrosswordCheats.com cheatography.com/mmorykan/ Last updated 28th January, 2020. Learn to solve cryptic crosswords! Page 1 of 2. http://crosswordcheats.com Common Commands Cheat Sheet by mmorykan via cheatography.com/89673/cs/20411/ Package / Networking (cont) User/Root Commands (cont) File and Directory Manipul​ ation (cont) tracer​ oute -I - Gives list of IPs the machine chmod 1777 filename - Sets all permiss​ ions awk '{print $1,$2,$3}' filename - Prints first, went through and a sticky bit second, third words of each line wget - Downloads file from internet sort - Sorts lines of text files Samba brctl, nmcli - Creates bridging between vi filename - Opens text editor for file. Hard ports smbpas​ swd - Sets server password to use file filename - Gives informa​ tion on file Other Stuff File and Directory Manipul​ ation more filename - Displays file contents (no Ctrl - U - Deletes command line ls - Shows all files in current directory scrolling) Ctrl - C - Aborts command ls -a - Shows all files including hidden files grep "t​ ext​ " filename - Searches for text in current directory Ctrl - Z - Suspends command within file pwd - Shows current directory (present fg - Resumes command after suspension find - Finds files working directory) Ctrl - T - Fix misspelled command whoami - Prints current user cd - Changes curent directory cal - Prints ASCII calendar rmdir - Removes directo​ ries pstree - Shows running processes as a tree du - Displays file space usage System Informa​ tion ps - Report a snapshot of current processes yes - Displays the same line of text until free - Displays amount of free and used cp - Copies files interru​ pted memory in system cp filename newfile​ name - Creates new file df - Reports file system disk space usage with old file informa​ tion lsblk - Reports informa​ tion about block cp filename directo​ ry/ - Puts file into devices directory fdisk - Manipul​ ates disk partition table mv - Moves files Uname - Prints system informa​ tion mv filename directo​ ry/ - Moves file into directory top - Display and update sorted info about processes rm - Removes​ \de​ letes files uptime - Displays the amount of timed the rm -r - Deletes directo​ ries machine has been running rm -r directo​ ry/ - Removes directory rm -rf directo​ ry/ - Removes directory to User/Root Commands oblivion useradd - Creates new user mkdir - Creates directo​ ries passwd - Sets password for new user echo - Moves data (e.g. moves text into a userdel - Removes user file) chsh --shell /bin/sh username - Changes echo text >> filename - Moves text into file shell cat - Reads file text or concate​ nate files and sudo grouped groupante - Creates group print file text chown - Changes owner touch - Creates any kind of file chgrp - Changes group tail - Outputs last part of files chmod - Changes permiss​ ions less - Views files instead of opening them. Lets user scroll through chmod ug +x filename - Gives user and group permission to execute file awk - Selects data and presents rows and columns in output By mmorykan Published 18th December, 2019. Sponsored by CrosswordCheats.com cheatography.com/mmorykan/ Last updated 28th January, 2020. Learn to solve cryptic crosswords! Page 2 of 2. http://crosswordcheats.com.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    2 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us