10 Useful ‘Interview Questions and Answers’ on Linux Shell Scripting

If You Appreciate What We Do Here On TecMint, You Should Consider:

  1. Stay Connected to: Twitter | Facebook | Google Plus
  2. Subscribe to our email updates: Sign Up Now
  3. Get your own self-hosted blog with a Free Domain at ($3.95/month).
  4. Become a Supporter - Make a contribution via PayPal
  5. Support us by purchasing our premium books in PDF format.
  6. Support us by taking our online Linux courses

We are thankful for your never ending support.

RedHat RHCE and RHCSA Certification Book
Linux Foundation LFCS and LFCE Certification Preparation Guide

You may also like...

22 Responses

  1. Sudhakar amineni says:

    Yes As said above by Zess, ls command is used for to see list of files.

    Its wrong what you mentioned here

  2. zen says:

    isn’t command ls used to list files in a directory?

    • Zool says:

      It meant to say “less” rather than “ls”. As it is, yeah. It’s wrong.

    • Warron French says:

      The way the question was asked wasn’t very clearly stated to accomplish the use of the command ls and echo to answer it in the affirmative and explain.

      The question should have been, “Is it possible to list the file and directory names of a given ‘parent directory’ using a command other than ‘ls?'”

      Yes, the use of “echo *” will perform the equivalent of a plain “ls.”

  3. jagan says:

    Hi,

    I need to execute a script on remote as a sudo user or root user from my local VM. It is not password less login. we need to pass password thorugh command line.

    #!/bin/bash
    sshpass -p “xxxx” ssh -o StrictHostKeyChecking=no [email protected] <<EOF
    echo "password" | 'sudo su -'
    sh script.sh
    EOF

    Note : there is no sshpass in remote server and we cannot install it for security reason.

    I am able to login to remote user as user but i can't login as a sudo user , Please help me how to achieve this. i have seen many quires but none one helped me

    -Thanks
    Jagan

    • Ravi Saive says:

      @Jagan,

      In CentOS, there isn’t any sudo user by default and the all the programs run with root privileges as root user, if you want to run enable sudo for user, you shoud use visudo command to enable it as shown:

      # visudo
      

      And add this entry to enable sudo privileges to your user.

      yourusername ALL=(ALL) ALL
      

Got something to say? Join the discussion.

Your email address will not be published. Required fields are marked *