top50_linux commands with explanation and interview Q&A
top50_linux commands with explanation and interview Q&A
2. cd
• Explanation: Changes the current directory.
• Example: cd /home/user (navigates to the specified directory).
3. pwd
• Explanation: Prints the current working directory.
• Example: pwd (shows the full path of the current directory).
4. mkdir
• Explanation: Creates a new directory.
• Example: mkdir new_folder (creates a directory named new_folder).
5. rmdir
• Explanation: Removes an empty directory.
• Example: rmdir old_folder (removes the specified empty directory).
6. rm
• Explanation: Removes files or directories.
• Example: rm file.txt (deletes the specified file).
7. cp
• Explanation: Copies files or directories.
• Example: cp source.txt destination.txt (copies source.txt to destination.txt).
8. mv
• Explanation: Moves or renames files or directories.
• Example: mv oldname.txt newname.txt (renames the file).
9. touch
• Explanation: Creates an empty file or updates the timestamp of an existing file.
• Example: touch newfile.txt (creates a new empty file).
10. cat
• Explanation: Concatenates and displays file content.
• Example: cat file.txt (displays the content of the file).
11. more
• Explanation: Views file content one screen at a time.
• Example: more file.txt (displays the content of the file with pagination).
12. less
• Explanation: Similar to more, but allows backward navigation.
• Example: less file.txt (displays the content of the file with backward navigation).
13. head
• Explanation: Displays the first few lines of a file.
• Example: head -n 10 file.txt (shows the first 10 lines).
14. tail
• Explanation: Displays the last few lines of a file.
• Example: tail -n 10 file.txt (shows the last 10 lines).
15. grep
• Explanation: Searches for a specific pattern in files.
• Example: grep 'search_term' file.txt (finds lines containing 'search_term').
16. find
• Explanation: Searches for files in a directory hierarchy.
• Example: find /path -name filename.txt (searches for filename.txt in the
specified path).
17. locate
• Explanation: Finds files by name quickly using a database.
• Example: locate filename.txt (finds the file using the database).
18. which
• Explanation: Shows the full path of a command.
• Example: which python (displays the path of the Python executable).
19. man
• Explanation: Displays the manual for a command.
• Example: man ls (shows the manual page for the ls command).
20. chmod
• Explanation: Changes file permissions.
• Example: chmod 755 file.txt (sets permissions to rwxr-xr-x).
21. chown
• Explanation: Changes file owner and group.
• Example: chown user:group file.txt (changes the owner and group).
22. ps
• Explanation: Displays currently running processes.
• Example: ps aux (shows detailed information about all processes).
23. top
• Explanation: Displays real-time system processes and resource usage.
• Example: top (opens the interactive process viewer).
24. kill
• Explanation: Sends a signal to terminate a process.
• Example: kill 1234 (terminates the process with PID 1234).
25. killall
• Explanation: Kills processes by name.
• Example: killall firefox (terminates all Firefox processes).
26. df
• Explanation: Displays disk space usage.
• Example: df -h (shows human-readable disk usage).
27. du
• Explanation: Displays disk usage of files and directories.
• Example: du -sh /path (shows total size of the specified path).
28. free
• Explanation: Displays memory usage.
• Example: free -m (shows memory usage in megabytes).
29. ifconfig
• Explanation: Displays or configures network interfaces (deprecated, use ip).
• Example: ifconfig (shows network interface configuration).
30. ip
• Explanation: Shows/manages network interfaces and routing.
• Example: ip addr show (displays IP addresses assigned to interfaces).
31. ping
• Explanation: Tests connectivity to a host.
• Example: ping google.com (checks if google.com is reachable).
32. traceroute
• Explanation: Traces the route packets take to a network host.
• Example: traceroute google.com (shows the path to google.com).
33. wget
• Explanation: Downloads files from the web.
• Example: wget http://example.com/file.zip (downloads the specified file).
34. curl
• Explanation: Transfers data from or to a server.
• Example: curl -O http://example.com/file.zip (downloads the file).
35. scp
• Explanation: Securely copies files between hosts.
• Example: scp file.txt user@remote:/path (copies file.txt to a remote server).
36. ssh
• Explanation: Connects to a remote server securely.
• Example: ssh user@remote (establishes an SSH connection).
37. tar
• Explanation: Archives files into a single file.
• Example: tar -cvf archive.tar /path (creates an archive).
38. gzip
• Explanation: Compresses files.
• Example: gzip file.txt (compresses the file).
39. gunzip
• Explanation: Decompresses gzip files.
• Example: gunzip file.txt.gz (decompresses the file).
40. zip
• Explanation: Compresses files into a zip archive.
• Example: zip archive.zip file1 file2 (creates a zip file).
41. unzip
• Explanation: Extracts files from a zip archive.
• Example: unzip archive.zip (extracts the contents).
42. history
• Explanation: Displays command history.
• Example: history (shows a list of previously executed commands).
43. alias
• Explanation: Creates shortcuts for commands.
• Example: alias ll='ls -l' (creates an alias for ls -l).
44. echo
• Explanation: Displays a line of text.
• Example: echo "Hello, World!" (prints the text).
45. env
• Explanation: Displays environment variables.
• Example: env (shows all environment variables).
46. export
• Explanation: Sets environment variables.
• Example: export VAR=value (creates an environment variable).
47. sudo
• Explanation: Executes commands with superuser privileges.
• Example: sudo apt update (runs the command as a superuser).
48. apt
• Explanation: Package management tool for Debian-based systems.
• Example: apt install package_name (installs a package).
49. yum
• Explanation: Package management tool for RPM-based systems.
• Example: yum install package_name (installs a package).
50. systemctl
• Explanation: Manages system services.
• Example: systemctl start service_name (starts a service).
9. What command would you use to download a file from the internet?
• Answer: You can use wget or curl to download files from the internet.
This document serves as a foundational guide to essential Linux commands and interview
preparation, equipping you with the knowledge needed for practical use and technical
discussions.
Linux commands follow for more Divya M . LinkedIn www.linkedin.com/in/divyam2000