Posts

Showing posts with the label Linux Command

Linux Basic Commands used in everyday activity

Image
  Here are some useful shortcuts which you may use while working on terminal: Cursor Movement Control: Ctrl-a : Move cursor to the start of a line Ctrl-e : Move cursor to the end of a line Ctrl-Left/Right: Navigate word by word (may not work in all terminals)Modify Text: Ctrl-w : Delete the whole word to the left of the cursor Ctrl-y : Undo the deleted word Ctrl-k : Erase to end of line Ctrl-u : Erase to beginning of line Crtl-l : Clear the terminal 2.  chown command :  Change the owner of a file or directory Parameters: -R:  Capital R  here means to change ownership of all sub-directories if found, and you must use this parameter if you use the command against a directory -f: means change ownership of all sub-directories as well as files also $chown root:root DirName $chown -R root:root DirName $chown -Rf root:root DirName 3.  chmod command : Change the permission of a fil e  or directory The mode which consists of 3 parts, owner, group, and o...

Advanced Linux Command Ease your Life

  Delete large File content immediately : Suppose large file name is access.log then different way to remove large content a. # > access.log b. # true > access.log c. # cat /dev/null > access.log d. # cp /dev/null access.log e. # dd if=/dev/null of=access.log g. # echo -n "" > access.log h. # truncate -s 0 access.log Search top 5 large file size files: #find /var/lib/docker/ -type f -exec du -Sh {} + | sort -rh | head -n 5 # du -a /var/lib/docker/ | sort -rh | head -5 Replacing words or characters:  If you are working with any text file then to replace every instance of any word say “version” with “story” in myfile.txt, you can use sed command as: # sed 's/version/story/g' myfile.txt Additionally, if you want to ignore character case then you may use gi instead of g as: # sed 's/version/story/gi' myfile.txt To Replace a whole line with input start of line parametre #sed -i -e '/^#PasswordAuthentication/s/^.*$/PasswordAuthentication yes/...