70 Linux Questions Asked During Interview


  1. How to check for Linux distribution name and version?
    cat /etc/*-release


  2. How to check kernel version?
    uname -a


  3. What is the purpose of "&" at the end of a command?
    With "&", the process starts in the background and you can continue using the same terminal.
  4. How to check system date/time?


  5. How to adjust system date/time?
    date --set="1 July 2017 15:22:00"


  6. How to shutdown a Linux machine from terminal?
    init 0


  7. In Ubuntu, what is the different between "apt-get update" and "apt-get upgrade"?
    apt-get update updates the list of available packages and their versions, but it does not install or upgrade any packages. apt-get upgrade actually installs newer versions of the packages you have.

  8. How to add a path into environment variable?

    export PATH=$PATH:/path/to/dir


  9. What is the purpose of "pwd" command?
    To view current working directory.

  10. If you wish to know more details about a command, which command you should use?
    Use "man":

    man ls


  11. How to execute multiple commands in one line?
    Use && symbol:

    cd /my_folder && rm *.tar.gz


  12. How to add a user into Super User group?

    gpasswd wheel -a <user>


  13. How do you change password?



  14. How to work in root environment?

    sudo -i


  15. How to view driver message?



  16. How to clear driver message?

    dmesg -c


  17. What is Yocto and how does it differ from other Linux distributions?
    While Ubuntu, Red Hat, CentOS are some of Linux distributions (distro), Yocto allows you to create your own Linux recipes and build your own distro. In most cases, Yocto image only contains components required, making file size much smaller which is essential for mobile platform such as IVI (In-Vehicle Infotainment) system. More information can be found in Yocto official website.

File Operations

  1. How to display files under current directory?


  2. How to show hidden files?
    ls -las


  3. How to calculate size of a directory?
    du -h SomeDir


  4. How to check disk usage?


  5. How to list down last 15 lines of a text file (e.g. error.log)?
    tail -n 15 error.log


  6. How to list down last 15 lines of a text file and keep the screen updated?
    tail -n 15 -f error.log


  7. How to find all files with certain file name?
    find / -name "filename"


  8. How to filter output by certain keyword?
    cat output.txt|grep SomeText


  9. How to change ownership of a file to another person?
    chown user2 SomeFile


  10. How to make a file executable?
    chmod +x <filename>


  11. In "chmod 777", what does 777 mean? 
    The first digit refers to permission for the owner of the file/directory. The second is group permission. Third is world permission. 777 means to give full permission to the world.
  12. What is umask and what does "umask 022" mean?
    When you create a file or directory in Linux, the particular file/directory will be given a default permission. "umask" allows you to change default permission. "umask 022", for example, will give the owner read, write and execute permissions whereas everyone else has read and execute permissions.
  13. How to create an empty file?
    touch empty.log


  14. How to edit a text file?
    Use vi or vim:
    vi example.txt


  15. How to softlink a file?
    ln -sf <existing_file> <link_to_create>
    For example:
    ln -sf iu3d_dri.so i965_dri.so


  16. Supposing you created a new directory call /mnt/WinDir. How do you mount a network Windows drive to this directory?
    mount -t cifs -o user=<username>,pass=<password> //<ip_addr>/<some_dir> /mnt/WinDir


  17. How to compress a directory into a Tarball?
    tar zcf NewFileName.tar.gz DirToCompress/


  18. How to save terminal output to a file?
    Use ">" sign, for exaple:
    startx > output.log


  19. How to copy a file to another location?
    cp /SomeDir/SomeFile /NewDir/NewFile 


  20. How to move a file to another location?
    mv /SomeDir/SomeFile /NewDir/SomeFile
  21. How to move a non-empty directory?
    rsync -a <source_directory> <target_directory>/
    rm -rf <source_directory>


  22. How to remove a non-empty directory?
    rm -rf <directory>



  1. How to list down all services available in a Linux machine?
    service --status-all


  2. What does the "+" and "-" signs mean in "service --status-all" command?
    "+" means the service is running whereas "-" is not.
  3. How to show processes using most memory?
    Run "top", then type "M" to sort by memory usage.
  4. Following the questio above, how to show only top 10 processes using most memory?
    While "top" is running, type "n", enter "10".
  5. How to check available memory?
    free -m


  6. How to kill a process?
    killall <process_name>
    - or -
    pkill <process_name>


  7. What is the purpose of "-9" in "kill -9 PID"?
    To kill a process forcefully.
  8. What is systemctl?
    To start/stop/restart/check status of a service.
  9. How to start a service?
    systemctl start <service>


  10. How you schedule a command to run at specific interval?
    Use cronjob. For example, if you with to run a script (e.g. example.sh) at 3am daily, run "crontab -e". Then, add the following line:
    00 3 * * * /bin/sh /scripts/example.sh


  11. In cronjob, there are 5 asterisks. What does each asterisk means?
    From left to right:
    1: [Minute]
    2: [hour]
    3: [Day_of_the_Month]
    4: [Month_of_the_Year]
    5: [Day_of_the_Week] 
  12. Without using cronjob, how to issue a command at specific interview (e.g. every 5 seconds)?
    Use "watch". The following command will execute "free -m" command every 5 seconds:
    watch -n 5 free -m



  1. What is the command to list down all IP addresses?


  2. How to ping an IP address for 5 times?
    ping -c 5


  3. What is the terminal command to download a file from Internet?
    wget <url>


  4. How do you access Linux terminal from a remote machine?
    Using SSH:
    ssh [email protected]_host


  5. How to transfer a file from e.g. Windows machine to Linux machine?
    Best way is to use WinSCP. Alternatively, use command:
    scp file.txt [email protected]:/opt/


  6. What are the default port for HTTP/FTP/SSH?
    HTTP: 80
    FTP: 21
    SSH: 22
  7. How to change SSH port?
    a) vi /etc/ssh/sshd_config
    b) Change "Port" value to desired value
    c) Save the file.
    d) Restart daemon: systemctl restart sshd.service
  8. How to FTP into a FTP server?
    ftp -i <domain_name>


  9. How to download multiple files from a FTP server?
    The following command will download all Tarballs to current local directory:

    mget *.tar.bz2


  10. How to upload multiple files to a FTP server?

    mput *.tar.bz2



  1. How to launch X11?


  2. How to kill X11?

    pkill x


  3. Why I can't run a X11 program from remote terminal?
    You need to export DISPLAY:

    export DISPLAY=:0


  4. How do you check for OpenGL version in X11?

    glxinfo|grep OpenGL


  5. How do you change screen resolution in X11?
    Use "xrandr" to check all available mode first, then:

    xrandr --output HDMI1 --mode 1024x768


  6. How to turn off X11 screen?

    xset dpms force off


  7. How do you launch Wayland?

    weston --tty=1 --idle-time=0


  8. How do you kill Wayland?

    killall weston


  9. I would like to say "Thank You" to the author of this article.
    Kindly like our Facebook page at https://www.facebook.com/littlecpu/

About the Author


CheeWah (Waco) has more than 10 years working experience in IT fields, especially in software development and testing. Some of the key projects included software development and support for production/R&D, software test automation, and Search Engine Optimisation (SEO). He is a food lover and has a food blog at www.noweating.com. Little CPU acts as his IT knowledge sharing hub.