Table of contents
SHELL
As a software engineer, understanding the basics of shell commands and scripting is essential for automating tasks, managing and manipulating files and directories, and interacting with the operating system. Shell, also known as a command-line interface (CLI), provides a text-based interface to interact with the computer, making it a powerful tool for developers. Whether you are working on Linux, macOS, or Windows, mastering the shell is a valuable skill that can help you streamline your workflow and make your day-to-day activities more efficient. With a deep understanding of shell commands and scripting, you can automate tasks, simplify complex processes, and make your work easier and more efficient.
What is shell
Shell is a program that takes command from the keyboard and gives it to the operating system to perform.
Shell interacts from the terminal
There are basic shell commands to work with.
Navigation
This is using shell commands to navigate the terminal.
Before understanding this we must know the UNIX/LINUX file structure.
The Linux file system hierarchy is a standardized way of organizing and storing files and directories on a Linux operating system. The hierarchy starts at the root directory (represented by "/") and branches out into subdirectories. The main branches of the hierarchy include:
/bin: Essential command binaries that need to be available in single user mode.
/boot: Boot loader files.
/dev: Device files that represent devices and physical hardware.
/etc: System-wide configuration files and scripts.
/home: User home directories, containing personal files and configuration.
/lib: Essential shared libraries.
/media: Mount points for removable media, such as CDs and DVDs.
/mnt: Temporarily mounted file systems.
/opt: Optional add-on application software packages.
/root: The home directory for the root user.
/sbin: System administration and system management executables.
/srv: Service data for specific system services.
/tmp: Temporary files.
/usr: User-related programs, libraries, and documentation.
/var: Variable data, such as log files and temporary files generated by system services.
Commands
- File Management
Commands | Description |
.. | Parent directory |
. | current directory |
cd(-) | Navigate the last directory |
cd (~)/ cd | Navigate to home |
- File Listing
commands | Description |
ls-a | List directory in long format |
ls -ld dir | List information about directory name instead of contents |
ls -a | list files including hidden |
ls -lt | sort with last time modification |
ls -lh | list file size in human-readable format |
ls -lr | Show all subdirectories recursively |
ls -f: is a special file listing command that needs a symbol to indicate the type
symbol | symbol name |
@ | symbolic link |
* | executable |
\= | socket |
> | directory |
Other Shortcuts to navigate the terminal
Command | Description |
CTRL+A | go to the beginning of the line |
CTRL+B | moves backward one character |
CTRL+C | stops the current command |
CTRL+D | deletes one character backward or logs out of the current session |
CTRL+E | go to the end of the line |
CTRL+F | moves forward one character |
CTRL+G | aborts the current editing command and rings the terminal bell |
CTRL+K | deletes (kill) forward to the end of line |
CTRL+L | clears the screen and redisplay the line |
CTRL+N | next line in the command history |
CTRL+R | searches in your command history |
CTRL+T | transposes two characters |
CTRL+U | kills backward to the beginning of the line |
CTRL+W | kills the word behind the cursor |
CTRL+Y | retrieves the last deleted string |
Conclusion
The shell may present a challenging task to master, but it is worth the effort as it opens up a world of possibilities.
As we continue our journey in the world of shell, we will delve deeper into its secrets and discover new ways to utilize its capabilities. It is important to stay informed and updated on the latest developments in the shell world to fully unlock its potential. So let's keep learning and exploring the shell together!
Follow me on LinkedIn.