DEV Community

Cover image for Essential Bash/Shell Commands for Beginners
BiKodes
BiKodes

Posted on

Essential Bash/Shell Commands for Beginners

Whether you're a developer, a student, or just curious about the command line, these basic Bash and Shell commands will help you navigate and manage files more efficiently.

bshell

TIPS

1. It’s recommended to add a space between commands and symbols, e.g.,cd .., not cd...

2. Some commands might not work in Windows PowerShell but will function in the Git Bash terminal, and vice versa. Always test in your preferred setup terminal.

File and Directory Navigation

ls
Enter fullscreen mode Exit fullscreen mode

Lists all files and folders in the current directory.

ls <folder_name>
Enter fullscreen mode Exit fullscreen mode

Displays all contents inside a specific folder.

cd ..
Enter fullscreen mode Exit fullscreen mode

Moves up to the parent directory.

cd <folder_name>
Enter fullscreen mode Exit fullscreen mode

Navigates to a specific folder. Use quotes if the folder name contains spaces, e.g., cd "My Documents".

pwd
Enter fullscreen mode Exit fullscreen mode

Prints the current working directory path.

start . (Windows) or open . (Mac)
Enter fullscreen mode Exit fullscreen mode

Opens the current folder in your default file explorer.

Creating Files and Folders

mkdir <folder_name>
Enter fullscreen mode Exit fullscreen mode

Creates a new folder.

touch <file_name>
Enter fullscreen mode Exit fullscreen mode

Creates a new file (with or without an extension), e.g., touch notes.txt.

Deleting Files and Folders

rm <file_name>
Enter fullscreen mode Exit fullscreen mode

Deletes a file permanently (use with caution!).

rmdir <folder_name>
Enter fullscreen mode Exit fullscreen mode

Deletes an empty folder.

⚠️ To delete a folder with contents, use rm -r <folder_name>.

System Operations

<drive_letter>: (Windows only)
Enter fullscreen mode Exit fullscreen mode

Switches to a different disk drive, e.g., E: or D:.

ren <old_name> <new_name>
Enter fullscreen mode Exit fullscreen mode

Renames a file or folder.

systeminfo (Windows only)
Enter fullscreen mode Exit fullscreen mode

Displays detailed system information.

shutdown /s (Windows only)
Enter fullscreen mode Exit fullscreen mode

Shuts down the system after a set time or immediately.

shutdown /l (Windows only)
Enter fullscreen mode Exit fullscreen mode

Logs out of the current user session.

Command Management

command1 & command2
Enter fullscreen mode Exit fullscreen mode

Runs multiple commands sequentially.

cls (Windows) or clear (Unix/Linux/macOS)
Enter fullscreen mode Exit fullscreen mode

Clears the terminal screen.

exit
Enter fullscreen mode Exit fullscreen mode

Closes the terminal session.

bshell

Final Tips

  1. Begin your journey by reading Linux for Beginners: An Introduction to the Linux Operating System and Command Line, a great starting point for anyone new to Linux and the command line.

  2. Practice these commands in a Git Bash terminal or Linux shell to get comfortable.

  3. Always double-check before using destructive commands, such as rm.

Got questions or want to explore advanced Bash scripting? Let us know in the comments or reach out on GitHub! Happy hacking!

Top comments (0)

Some comments may only be visible to logged-in visitors. Sign in to view all comments.