Skip to main content

Posts

Showing posts from January, 2016

Create and delete File/ Directory in Linux:

  Command Description touch Create a 0 bytes file cat > filename Create a file and allow to write (ctrl+c) to exit Override cat >> filename Add content to the existing file Appending vi Create a file if doesn’t exist and add the content in the vi editor rm Remove a file Ex: rm filename rm -f Remove a file forcefully Ex: rm -f filename mkdir Create a Directory rmdir Remove a empty directory rm -rf Remove a directory forcefully Ex: rm -rf dir ls -l Long Listing (In Alphabetic order) ls -lt ...

Commands for Reading a file in Linux

  Command Description ls Directory listing cat filename View file content less View file page by page Ex: less < filename> It will display a page. If we enter space we will get another page If we want to exit please click Q or q on your keyboard page Display file page by page (Ubuntu flavor) more Output the contents of the file Ex: more filename head Output the required number of lines from top to bottom in a file Ex: head -5 filename tail Output the required number of lines from bottom to top in a file Ex: tail -5 filename