HB Computer Security | Aide Memoire
  • Introduction
  • Core Technical Skills
    • Core Skills
      • Linux
        • Getting to Know Linux
          • Using the Shell
            • Shells, Terminals, and Virtual Consoles
            • Choose your Shell
            • Shell Commands
              • Non-PATH Commands
              • Command History
                • Command Line Editing
                  • Keystrokes for Navigating Command Lines
                  • Keystrokes for Editing Command Lines
                  • Keystrokes for Cutting and Pasting Text from within Command Lines
                • Command Line Recall
                  • Keystrokes for Command Line Recall
              • Connecting and Expanding Commands
                • Piping Between Commands
                • Sequential Commands
                • Expanding Commands
            • Shell Variables
              • Common Shell Variables
            • Aliases
            • Create your Own Shell Environment
              • Modification Ideas
          • Navigating the Linux File System (LFS)
            • Filesystem Commands
            • Listing Files and Directories
            • File Permissions and Ownership
              • Modifying Permissions with chmod
              • Modifying Default Permissions with umask
              • Change File Ownership with chown
            • Copying, Moving, and Removing Files
            • Finding Files
              • locate
              • find
              • grep
            • Downloading Files
              • axel
              • wget
              • curl
                • User-Agent: Googlebot
          • Working with Text Files
            • Using vim and vi to Edit Text Files
              • Starting with vi
              • Adding Text
              • Moving Around in the Text
            • Text Manipulation
        • System Administration
          • Installing Linux
            • Installing from Live Media
            • Installing in the Enterprise
            • Partitioning Hard Disks
              • Tips for Creating Partitions
          • Account Administration
            • The root Account
              • Becoming root with su
              • sudo
                • The /etc/sudoers File
                • Granting sudo privileges
                  • visudo Guidance
                • Useful sudo Hints
            • Other Administrative Accounts
            • Standard User Accounts
              • Risks of userdel: Orphaned Files
          • Graphical Remote Administration
            • Cockpit
              • Installation Guide
            • Remote Desktop Protocol with xrdp
              • Installation and Configuration
            • Remote Desktop with vnc
              • Installation and Configuration
              • Running VNC as a System Service
          • Managing Running Processes
            • Listing Processes
              • ps
              • top
              • htop
            • Backgrounding and Foregrounding
              • Starting a Background Process
              • Using Foreground and Background Commands
            • Killing and Recining Processes
              • kill and killall
          • Managing Software
            • Managing Software from the Desktop
            • Going Beyond the Limitations of Software Center
              • Debian Packages
                • Advanced Package Tool (apt)
                • Repositories
                • dpkg
        • Shell Scripting
          • Variables
            • Command Substitution
            • Arguments
          • Reading User Input
          • if, else, and elif
          • BOOLEAN Logic
          • Loops
            • for Loops
            • while Loops
          • Functions
          • Local Vs Global Variables
          • Summary
        • Securing Linux
      • Windows
        • Security Hardening
Powered by GitBook
On this page
  • Configure your Shell

Was this helpful?

  1. Core Technical Skills
  2. Core Skills
  3. Linux
  4. Getting to Know Linux
  5. Using the Shell

Create your Own Shell Environment

We can always customise the shell for a more efficient, personal workflow. For exmaple, setting up aliases for frequently used commands and establishing environment variables for specific details, your tasks become streamlined. Including these configurations in your shell's setup files ensures they're at your fingertips every time you initiate a new shell session.

Configure your Shell

Various configuration files dictate the behaviour of your shell. While some are applied universally for every user and shell session, others cater to individual users. The following table highlights the essential files for anyone utilising the bash shell in Linux:

File

Description

/etc/profile

This sets up user environment information for every user. It is executed when you first log in. This file provides values for your PATH, in addition to setting environment variables for such things as the location of your mailbox and the size of your history files.

Finally, /etc/profile gathers shell settings from configuration files in the /etc/profile.d directory.

/etc/bashrc

This executes for every user who runs the bash shell, each time a bash shell is opened. It sets the default prompt and may add one or more aliases. Values in this file can be overridden by information in each user’s ~/.bashrc file.

~/.bash_profile

This is used by each individual user to enter information that is specific to his or her use of the shell. It is executed only once — when the user logs in. By default, it sets a few environment variables, and executes the user’s ~/.bashrc file.

This is a good place to add environment variables because, once set, they are inherited by future shells.

~/.bashrc

This contains the information that is specific to each users bash shells. It is read when you log in and also each time you open a new bash shell. This is the best location to add aliases so that your shell picks them up.

~/.bash_logout

This executes each time you log out (exit the last bash shell).

Notice the use of ~ in the filenames to indicate that the file is located in the users home directory.

To modify the /etc/profile or /etc/bashrc files, you need root (superuser) privileges. However, rather than editing these files directly, it's advisable to set up an /etc/profile.d/custom.sh file for system-wide configurations.

Individual users have the freedom to alter the contents of the $HOME/.bash_profile, $HOME/.bashrc, and $HOME/.bash_logout files within their personal directories.

See the next section for some neat ideas on customisation.

PreviousAliasesNextModification Ideas

Last updated 1 year ago

Was this helpful?