Saturday 10 May 2014

More Linux shell commands

less  fileName => opens the file a page at a time.  SHIFT+G will move to the end of the file.


tail -3 fileName => open the file at the end showing just the last 3 lines that end with new line


mkdir  -p   a/b/c   => create empty directory structure in the current directory. If /a/b/c is used, then it will be created in the root of the system, if you have permissions.


rmdir -pv a/b/c  => remove the whole folder structure, starting from the bottom to top. The structure to delete must be explicitly described (a/b/c).
-p is the same option as above (parent)
-v is verbose output of all steps the command performs



ls -R folderName   => list recursively the content of the folder structure inside the folderName
ls -d  */     -> list only the directories in the current folder. * is all, / is just subfolders one level below.
                      To go deeper, add more */*/



u  user
g group
o other
chmod u+x file  -> set exec right to the owner (user)
chmod u=x file    -> set only exec right to the user (owner) of the file
chmod ugo=r  file   -> set only read rights to all three, user, group, others
chmod g=wx  file   -> set write and exec rights for the group
chmod a-rwx file   -> remove all three rights for all three kinds of users (owner,group,other)
chmod 000  file   -> same as above
chmod u+rwx,g+r,o+r  file  ->  set user all rights, group read and other read.
                                               No space around the comma.




No comments:

Post a Comment