My file bash, and configurate for linux

http://ariaf.my.id/linux_aria/linux_dasar/1.html


1

shorcut

  • ctrl L => clear screen
  • ctrl u => clear left cursor
  • ctrl k => clear right cursor

tips command

## term
clear # clear screen
reset # terminal initialization ( reset sreen if ur term broken )

## help
whatis <commanad>
help <command>
man <command> / info <command>
apropos <command> # list command
whereis <command> # see locate command
locate <command> # locate command

## history
history
history 5 # show -5 ur history
history -c # clear history
!35 # run history number
!! # run previous history
!-5 # run -5 history
 cd /home # pake spasi jika tidak ingin nampil di history
## command
pwd # show working directory
cd # change directory

## relative
cd / # root directory
cd /home/ariafatah/Document

## absolute
cd etc
cd nginx/html
cd .. # change dir back
cd ../../ # change directory 2 back
cd ~ # change directory curent user
cd - # change directory back to previous
cd 

list

ls
ls -a # show dir and hidden file
ls -l # more information list
ls -al / ls -a -l
ll => same ls -al

create dir, file, show file

mkdir dir
mkdir dir1 dir2
mkdir -p a/b/c/d/e

tree
tree -L <level>

touch file.txt
echo "web 1" > index.html

cat > file2.txt
###
a
a
###
ctrl + d

basic file operation

## copy
cp file1 copy_file1
cp file1 /tmp # copy file to dir
cp file* /tmp # copy file with regex to directory
cp -r folder1/ folder2/ # copy folder

## move, rename
mv folder1/ folder2
mv file1 file2 # rename
rm file2
rm -r folder # r => recursive, f=> force

view file

wget http://url/file.txt
cat file.txt

more file.txt
more -10 file.txt # have 10 line move
more +145 file.txt # start in 145 line
more +/media -5 file.txt
more -s

less file.txt
less -p "media" file.txt # pattern
less -ip "media" file.txt # pattern with case insensitive
less -N file.txt # with line number

head file.txt # output first line default n 10
head -n 20 file.txt 
head -20
head -c 10 # output file with byte
head -c 10k / 10m

tail file.txt # output last line default 10

Docs

List of Linux Terminal Hotkeys

| Category | Shortcut | Action | |———————-|——————————-|———————————————————————————————| | Bash Navigation | Ctrl + A | Move to the start of the command line | | | Ctrl + E | Move to the end of the command line | | | Ctrl + F | Move one character forward | | | Ctrl + B | Move one character backward | | | Ctrl + XX | Switch cursor position between start of the command line and the current position | | | Ctrl + ] + x | Move the cursor forward to the next occurrence of x | | | Alt + F / Esc + F | Move the cursor one word forward | | | Alt + B / Esc + B | Move the cursor one word backward | | | Alt + Ctrl + ] + x | Move cursor to the previous occurrence of x | | Bash Control/Process | Ctrl + L | Clear the terminal screen (similar to clear command) | | | Ctrl + S | Stop command output to the screen | | | Ctrl + Z | Suspend current command execution and move it to the background | | | Ctrl + Q | Resume suspended command | | | Ctrl + C | Send SIGINT signal to kill the currently executing command | | | Ctrl + D | Close the current terminal | | Bash History | Ctrl + R | Incremental reverse search of bash history | | | Alt + P | Non-incremental reverse search of bash history | | | Ctrl + J | End history search at the current command | | | Ctrl + _ | Undo previous command | | | Ctrl + P / Up arrow | Move to the previous command | | | Ctrl + N / Down arrow | Move to the next command | | | Ctrl + S | Get the next most recent command | | | Ctrl + O | Run and re-enter the command found via Ctrl + S or Ctrl + R | | | Ctrl + G | Exit history search mode | | | !! | Run the last command | | | !* | Run the previous command except its first word | | | !*:p | Display what !* substitutes | | | !x | Run the recent command in history that begins with x | | | !x:p | Display the x command and add it as the recent command in history | | | !$ | Bring forth the last argument of the previous command | | | !^ | Substitute the first argument of the last command in the current command | | | !$:p | Display the word that !$ substitutes | | | ^123^abc | Replace 123 with abc | | | !n:m | Repeat arguments within a range (e.g., 2-3) | | | !fi | Repeat the latest command in history that begins with fi | | | !n | Run the nth command from the bash history | | | !n:p | Print the command !n executes | | | !n:$ | Repeat arguments from the last command (e.g., from argument n to $) | | Bash Editing | Ctrl + U | Delete before the cursor until the start of the command | | | Ctrl + K | Delete after the cursor until the end of the command | | | Ctrl + W | Remove the command/argument before the cursor | | | Ctrl + D | Remove the character under the cursor | | | Ctrl + H | Remove the character before the cursor | | | Alt + D | Remove from the character until the end of the word | | | Alt + Backspace | Remove from the character until the start of the word | | | Alt + . / Esc + . | Use the last argument of the previous command | | | Alt + < | Move to the first line of the bash history | | | Alt + > | Move to the last line of the bash history | | | Esc + T | Switch between the last two words before the cursor | | | Alt + T | Switch the current word with the previous one | | Bash Information | TAB | Autocomplete the command or file/directory name | | | ~TAB TAB | List all Linux users | | | Ctrl + I | Complete the command like TAB | | | Alt + ? | Display files/folders in the current path for help | | | Alt + * | Display files/folders in the current path as parameters |