From d72427744b3959c48d6ee4c6c3ca68727fc42ace Mon Sep 17 00:00:00 2001 From: Sandipan Chatterjee <79105018+sandy3002@users.noreply.github.com> Date: Mon, 24 Oct 2022 00:44:01 +0530 Subject: [PATCH 1/2] Create bash.txt --- bash/bash.txt | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 bash/bash.txt diff --git a/bash/bash.txt b/bash/bash.txt new file mode 100644 index 0000000..f55a69f --- /dev/null +++ b/bash/bash.txt @@ -0,0 +1,43 @@ +# SHORTCUTS and HISTORY +############################################################################## + +CTRL+A # move to beginning of line +CTRL+B # moves backward one character +CTRL+C # halts the current command +CTRL+D # deletes one character backward or logs out of current session, similar to exit +CTRL+E # moves to end of line +CTRL+F # moves forward one character +CTRL+G # aborts the current editing command and ring the terminal bell +CTRL+H # deletes one character under cursor (same as DELETE) +CTRL+J # same as RETURN +CTRL+K # deletes (kill) forward to end of line +CTRL+L # clears screen and redisplay the line +CTRL+M # same as RETURN +CTRL+N # next line in command history +CTRL+O # same as RETURN, then displays next line in history file +CTRL+P # previous line in command history +CTRL+Q # resumes suspended shell output +CTRL+R # searches backward +CTRL+S # searches forward or suspends shell output +CTRL+T # transposes two characters +CTRL+U # kills backward from point to the beginning of line +CTRL+V # makes the next character typed verbatim +CTRL+W # kills the word behind the cursor +CTRL+X # lists the possible filename completions of the current word +CTRL+Y # retrieves (yank) last item killed +CTRL+Z # stops the current command, resume with fg in the foreground or bg in the background + +ALT+B # moves backward one word +ALT+D # deletes next word +ALT+F # moves forward one word +ALT+H # deletes one character backward +ALT+T # transposes two words +ALT+. # pastes last word from the last command. Pressing it repeatedly traverses through command history. +ALT+U # capitalizes every character from the current cursor position to the end of the word +ALT+L # uncapitalizes every character from the current cursor position to the end of the word +ALT+C # capitalizes the letter under the cursor. The cursor then moves to the end of the word. +ALT+R # reverts any changes to a command you’ve pulled from your history if you’ve edited it. +ALT+? # list possible completions to what is typed +ALT+^ # expand line to most recent match from history + + From facbe056d996e9abf892105bb294a437a97e5136 Mon Sep 17 00:00:00 2001 From: Sandipan Chatterjee <79105018+sandy3002@users.noreply.github.com> Date: Tue, 25 Oct 2022 08:26:56 +0530 Subject: [PATCH 2/2] Update bash.txt --- bash/bash.txt | 75 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) diff --git a/bash/bash.txt b/bash/bash.txt index f55a69f..5481169 100644 --- a/bash/bash.txt +++ b/bash/bash.txt @@ -41,3 +41,78 @@ ALT+? # list possible completions to what is typed ALT+^ # expand line to most recent match from history +# BASH BASICS +############################################################################## + +env # displays all environment variables + +echo $SHELL # displays the shell you're using +echo $BASH_VERSION # displays bash version + +bash # if you want to use bash (type exit to go back to your previously opened shell) +whereis bash # locates the binary, source and manual-page for a command +which bash # finds out which program is executed as 'bash' (default: /bin/bash, can change across environments) + +clear # clears content on window (hide displayed lines) + + +# FILE COMMANDS +############################################################################## + + +ls # lists your files in current directory, ls to print files in a specific directory +ls -l # lists your files in 'long format', which contains the exact size of the file, who owns the file and who has the right to look at it, and when it was last modified +ls -a # lists all files in 'long format', including hidden files (name beginning with '.') +ln -s # creates symbolic link to file +readlink # shows where a symbolic links points to +tree # show directories and subdirectories in easilly readable file tree +mc # terminal file explorer (alternative to ncdu) +touch # creates or updates (edit) your file +mktemp -t # make a temp file in /tmp/ which is deleted at next boot (-d to make directory) +cat # displays file raw content (will not be interpreted) +cat -n # shows number of lines +nl # shows number of lines in file +cat filename1 > filename2 # Copy filename1 to filename2 +cat filename1 >> filename2 # merge two files texts together +any_command > # '>' is used to perform redirections, it will set any_command's stdout to file instead of "real stdout" (generally /dev/stdout) +more # shows the first part of a file (move with space and type q to quit) +head # outputs the first lines of file (default: 10 lines) +tail # outputs the last lines of file (useful with -f option) (default: 10 lines) +vim # opens a file in VIM (VI iMproved) text editor, will create it if it doesn't exist +mv # moves a file to destination, behavior will change based on 'dest' type (dir: file is placed into dir; file: file will replace dest (tip: useful for renaming)) +cp # copies a file +rm # removes a file +find . -name # searches for a file or a directory in the current directory and all its sub-directories by its name +diff # compares files, and shows where they differ +wc # tells you how many lines, words and characters there are in a file. Use -lwc (lines, word, character) to ouput only 1 of those informations +sort # sorts the contents of a text file line by line in alphabetical order, use -n for numeric sort and -r for reversing order. +sort -t -k # sorts the contents on specific sort key field starting from 1, using the field separator t. +rev # reverse string characters (hello becomes olleh) +chmod -options # lets you change the read, write, and execute permissions on your files (more infos: SUID, GUID) +gzip # compresses files using gzip algorithm +gunzip # uncompresses files compressed by gzip +gzcat # lets you look at gzipped file without actually having to gunzip it + + + +# SSH, SYSTEM INFO & NETWORK COMMANDS +############################################################################## + + +ssh user@host # connects to host as user +ssh -p user@host # connects to host on specified port as user +ssh-copy-id user@host # adds your ssh key to host for user to enable a keyed or passwordless login + +whoami # returns your username +su # switch to a different user +su - # switch to root, likely needs to be sudo su - +sudo # execute command as the root user +passwd # lets you change your password +quota -v # shows what your disk quota is +date # shows the current date and time +cal # shows the month's calendar +uptime # shows current uptime +w # displays whois online +finger # displays information about user +uname -a # shows kernel information +man # shows the manual for specified command