1. Command Line Basics
Shell and Shell Types:
- Bash: Bash (Bourne-Again Shell) is the default shell in RHEL, offering numerous built-in commands and scripting capabilities, making it efficient for system administration tasks.
- Other Shells: While Bash is the most commonly used, knowing other shells like zsh or sh can be helpful for specialized tasks or when working in environments with different default shells.
Prompt Symbols:
- The $ symbol in the prompt indicates a regular user, while # shows you’re in the superuser (root) environment.
- The prompt may include other information, such as the username, hostname, and current directory path, which is customizable in Bash by modifying the PS1 variable.
2. Shell Command Structure
Commands in the shell are structured with:
- Command: This tells the shell what operation to perform.
- Options: Modify the command’s behavior (e.g., -L in usermod -L user01, which locks the account).
- Arguments: Specifies the target or resources the command affects.
Example with Explanation:
usermod -L user01
- usermod: Command to modify user accounts.
- -L: Locks the specified user account, meaning it cannot be logged into until unlocked.
- user01: Target user account.
Common Commands:
- ls: Lists files and directories.
- pwd: Displays the present working directory.
- cd: Changes directories.
- cp: Copies files and directories.
- mv: Moves or renames files and directories.
Practice Tip: Practice commands with various options and arguments to understand their behavior in different scenarios, especially those relevant to user management and file handling.
3. Logging In
Local Login:
- Local login occurs directly through a text or graphical console.
- In environments with only command-line interfaces, understanding tty (teletypes) is helpful, as each terminal session is associated with a tty identifier, which can be accessed with the tty command.
Virtual Consoles:
- Virtual consoles allow switching between multiple login sessions.
- Access these with Ctrl+Alt+F1 to F6, each corresponding to a different console session. They’re especially useful in server environments where you may want to perform different tasks across separate consoles.
4. Remote Login (SSH)
SSH Basics:
- Secure Shell (SSH) allows for encrypted communication with remote servers, a crucial part of remote administration.
- Syntax: ssh username@hostname
- Example: ssh admin@192.168.1.10 will prompt for admin's password on the machine with IP 192.168.1.10.
Public Key Authentication:
- For enhanced security, SSH offers public key authentication, where the user’s identity is verified by a key pair instead of a password.
- To use a private key: ssh -i /path/to/private_key.pem user@hostname
- To set up key-based authentication, generate a key pair using ssh-keygen, then copy the public key to the remote server’s ~/.ssh/authorized_keys file for the relevant user.
5. Logging Out
Ending a Session:
- To log out, use the exit command or press Ctrl+D to close the session gracefully.
- This command is the same for both local and remote (SSH) sessions, ensuring you properly terminate connections and free resources.
Post a Comment