Linux Fundamentals 4
Linux Fundamentals 4
Prompt Description
Cheat Sheet
The bash prompt is easy to understand and, by default, includes information such as the user, hostname, and current working
directory. It is a string of characters displayed on the terminal screen that indicates that the system is ready for our input. It typically Table of Contents
includes information such as the current user, the computer’s hostname, and the current working directory. The prompt is usually Introduction
displayed on a new line, and the cursor is positioned after the prompt, ready for the user to start typing a command. Linux Structure
It can be customized to provide useful information to the user. The format can look something like this: Linux Distributions
Introduction to Shell
Prompt Description
The home directory for a user is marked with a tilde <~> and is the default folder when we log in. Getting Help
System Information
Work ow
<username>@<hostname>[~]$
Navigation
Working with Files and Directories
The dollar sign, in this case, stands for a user. As soon as we log in as root, the character changes to a hash <#> and looks like this:
Editing Files
Find Files and Directories
root@htb[/htb]#
File Descriptors and Redirections
Filter Contents
For example, when we upload and run a shell on the target system, we may not see the username, hostname, and current working
Regular Expressions
directory. This may be due to the PS1 variable in the environment not being set correctly. In this case, we would see the following
prompts:
Permission Management
System Management
Unprivileged - User Shell Prompt
User Management
Package Management
$
Service and Process Management
Task Scheduling
Working with Web Services
Backup and Restore
#
File System Management
In addition to providing basic information like the current user and working directory, we can customize to display other information
Containerization
in the prompt, such as the date and time, IP address, date, time, the exit status of the last command, and more. This is especially
Linux Networking
useful for us during our penetration tests because we can use various tools and possibilities like script or the .bash_history to
Network Con guration
lter and print all the commands we used and sort them by date and time. For example, the prompt could be set to display the full
path of the current working directory instead of just the current directory name, which can also include the target’s IP address if we Remote Desktop Protocols in Linux
work organized.
Linux Hardening
The prompt can be customized using special characters and variables in the shell’s con guration le (.bashrc for the Bash shell). Linux Security
For example, we can use: the \u character to represent the current username, \h for the hostname, and \w for the current working
Firewall Setup
directory.
System Logs and Monitoring
\n Newline My Workstation
\r Carriage return
Customizing the prompt can be a useful way to make your terminal experience more personalized and e cient. It can also be a
helpful tool for troubleshooting and problem-solving, as it can provide important information about the system’s state at any given
time.
In addition to customizing the prompt, we can customize their terminal environment with di erent color schemes, fonts, and other
settings to make their work environment more visually appealing and easier to use.
However, we see the same as when working on the Windows GUI here. We are logged in as a user on a computer with a speci c
name, and we know which directory we are in when we navigate through our system. Bash prompt can also be customized and
changed to our own needs. The adjustment of the bash prompt is outside the scope of this module. However, we can look at the
bashrcgenerator and powerline, which gives us the possibility to adapt our prompt to our needs.
Powered by