Bash cheat sheet: What are Top 25 commands?

Free Coding Questions Catalog
Boost your coding skills with our essential coding questions catalog. Take a step towards a better tech career now!

Bash (Bourne Again SHell) is a powerful command line interface (CLI) and scripting language used in many operating systems, including Linux and macOS. Knowing key Bash commands can greatly enhance productivity and system management. Here's a cheat sheet of the top 25 Bash commands that are essential for users ranging from beginners to experienced developers:

1. ls

Lists directory contents.

  • ls -l: Lists with detailed information.
  • ls -a: Lists all files, including those starting with ..

2. cd

Changes the current directory.

  • cd /path/to/directory: Changes to specified directory.
  • cd: Changes to the home directory.
  • cd ..: Moves up one directory level.

3. pwd

Prints the current directory path.

4. mkdir

Creates a new directory.

  • mkdir directory_name

5. rmdir

Removes an empty directory.

6. rm

Removes files or directories.

  • rm filename: Removes a file.
  • rm -r directory_name: Recursively removes a directory and its contents.

7. cp

Copies files or directories.

  • cp source destination: Copies source file to destination.

8. mv

Moves or renames files or directories.

  • mv source destination: Moves/renames source to destination.

9. touch

Creates a new empty file or updates the timestamp of an existing file.

  • touch filename

10. cat

Concatenates and displays files.

  • cat file: Displays file contents.

11. echo

Displays a line of text or variables.

  • echo "Hello World"

12. grep

Searches text using patterns.

  • grep "pattern" file: Searches for a pattern in a file.

13. find

Searches for files in a directory hierarchy.

  • find /path -name filename

14. chmod

Changes file mode bits.

  • chmod +x filename: Makes the file executable.

15. chown

Changes file owner and group.

  • chown user:group filename

16. ps

Displays information about active processes.

  • ps aux: Shows all running processes.

17. kill

Sends a signal to a process, usually to stop the process.

  • kill PID: Kills process with specified PID.

18. df

Shows disk space usage.

  • df -h: Shows disk space in human-readable form.

19. du

Shows disk usage by files or directories.

  • du -sh directory_name: Shows summary of directory size.

20. top

Displays dynamic real-time information about running processes.

21. man

Displays the manual pages for commands.

  • man command: Shows the manual for the command.

22. history

Displays the command history.

23. alias

Creates an alias for a command.

  • alias ll='ls -l': Creates an alias ll for ls -l.

24. wget

Downloads files from the internet.

  • wget URL: Downloads file from the specified URL.

25. curl

Transfers data from or to a server.

  • curl URL: Fetches the content of a URL.

These commands form the backbone of daily command line operations and are invaluable for system navigation, file management, process control, and network activities. Mastery of these commands can significantly enhance your efficiency and effectiveness in a Bash environment.

TAGS
System Design Interview
CONTRIBUTOR
Design Gurus Team

GET YOUR FREE

Coding Questions Catalog

Design Gurus Newsletter - Latest from our Blog
Boost your coding skills with our essential coding questions catalog.
Take a step towards a better tech career now!
Explore Answers
How to gain confidence as a software engineer?
How to Approach Coding Questions in FAANG Interviews Without Panicking
How to pass an interview at Meta?
Related Courses
Image
Grokking the Coding Interview: Patterns for Coding Questions
Image
Grokking Data Structures & Algorithms for Coding Interviews
Image
Grokking Advanced Coding Patterns for Interviews
Image
One-Stop Portal For Tech Interviews.
Copyright © 2024 Designgurus, Inc. All rights reserved.