Skip to content

Latest commit

 

History

History
60 lines (40 loc) · 2.01 KB

linux-markdown.md

File metadata and controls

60 lines (40 loc) · 2.01 KB

Linux Basics

echo Hi will print to screen

ls will list files and folders in current location

cd will change the directory by using cd followed by the file or folder

pwd will print the currently directory you are in

mkdir will make a new folder / directory

cd new_directory; mkdir new_folder; pwd you can run multiple commands by using the semicolon followed by the next command in order. In this example it will enter into the new_directory, create a new folder and then present the current workign directory

mkdir -p /tmp/asia/india/bangalore by using the -p command we can create a directory tree in one command input instead of creating each directory or folder individually

rm -r /tmp/my_dir1 this will remove the directory called my_dir1

cp -r my_dir1 /tmp/my_dir1 will copy the directory called my_dir1

touch new_file.txt will create a new text file called new_file in the current directory

cat > new_file.txt add text to the file then control + d to exit

cat new_file.txt to view the contents of the file

cp new_file.txt copy_file.txt this will copy the file

mv new_file.txt sample_file.txt this will move file, if its in the same location it will work as if its renamed

rm new_file.txt to remove a file

VI editor Linux

vi index.html opens the editor in command mode
-type i to enter insert mode
-press esc to go back to command mode
-move around using the arrow keys or 'k' for up 'h' for left 'j' for down 'l' for right
-to delete a character press 'x' or 'dd' to delete the whole line
-to copy a line type 'yy' and to paste it type 'p'
-type :w to save the command
-type :w example to save the a file called filename
-type :q to quit / discard changes -type :wq to save the file and quit
-type /of to find text 'of' followed by 'n' to find the next occurance of that specific text -type