Thursday, 18 October 2018

Linux Useful Commands


  1. Check if the command can be executed by some user? 

    > su -s /bin/bash <your_user_to_test>

    This command will give you the shell with same privileges as the user you want to test the command.
    then you can type the command that you want to test and check.
  2. Read a file inside the tar ball,
    Find out the path of the embedded archive file that we wish to list or see:
    tar -tzf outer.tar.gz | grep tar

    Assume the ouput is `path/to/inner.tar`.
    then the command to,
    1.  list from the inner tar would be,
                tar -xOf outer.tar.gz path/to/inner.tar | tar -tf -
    1.   see the content of the file inside the inner tar is,
            tar -xOf outer.tar.gz path/to/inner.tar | tar -xOf - inner/some_file.txt | less

     3. To print all the words, containing the given word,
        grep -E 'rust|rs$' /usr/share/dict/words | perl -MList::Util=shuffle -e 'print shuffle(<STDIN>);' | less 

note:- in this change the word rust to whatever you want to search


DS points for reference:-