Hack Like a Pro: Linux Basics for the Aspiring Hacker, Part 9 (Managing Environmental Variables) « Null Byte :: WonderHowTo

Welcome back, my aspiring hackers!One of the areas that often gives Linux newcomers problems are the environment variables. Although Windows systems have environment variables, most users, and for that matter, most administrators, never manage their environment variables. To get the most from ourLinux hacking system, we need to both understand environment variables and be able to manage them for optimal performance.Environment variables are the variables that are used by our particular user environment. In most cases, this will be our BASH shell. Each user, including root, has a set of environment variables that are set at default values unless they're changed. We can change these values to make our system work more efficiently and tailor our work environment to best meet our individual needs.Step 1: View Our Environment VariablesWe can view our environment variables by typing:setNotice thatsetlists for us all of the environment variables, user defined functions, and aliases. Also, make note that our environment variables are always UPPER CASE names such asHOME,PATH,HISTSIZE, etc.If want to see the value inside the variable, we can type:echo $HISTSIZEIt's important to notice that when we want to use the value inside the variable, such as here, we need to put a$before the variable name.TheHISTSIZEvariable contains the value of the number of commands that are stored in our history file. As you can see in this screenshot, the HISTSIZE variable is set to 1000. In some cases, we may not want our commands stored in the history file, such aswhen we are covering our tracks, then we can set our HISTSIZE variable to zero.HISTSIZE=0When we change an environment variable, it's only for that environment. This means that once we close that terminal, any changes that we made to these variables is lost or set back to the default value. If we want the value to remain for our next terminal session and other terminal sessions, we need to export the variable. We can do this by simply typing:export HISTSIZEStep 2: Changing Our Terminal PromptLet's have a little fun and change the prompt in our terminal. The environment variable that contains our prompt for the first terminal isPS1. We can change it by typing:PS1= "World's Best Hacker: #"Remember that our prompt will now be "World's Best Hacker" whenever we open the first terminal (PS1), but the second terminal will still be the defaultBackTrackcommand prompt. In addition, if we really like this command prompt and want to keep it, we need to export it so that each time we open this terminal, the prompt will be "World's Best Hacker."export PS1Step 3: Changing Our Path VariableProbably the most important variable in our environment is ourPATHvariable. This is what controls where our shell looks for the commands we type, such ascd,ls,echo, etc. If it doesn't find the command in one of the directories in our path, it returns an error "command not found," even if it DOES exist in another directory not in our PATH.Let's take a look at our path variable:echo =$PATHNotice the directories included in our PATH. These are usually the various/binand/sbindirectories where our system variables are found. When we typels, the system knows to look in each of these directories for thelscommand.Whenever we want to useaircrack-ngor another hacking application in this PATH variable, we have to first navigate to that directory. In the case of aircrack-ng, that would be/pentest/wireless/aircrack-ng.Now, if we want to add ourwireless hackingapplication to our PATH variable, we can type:PATH=$PATH:/pentest/wireless/aircrack-ngNow when we want to run aircrack-ng, we don't need to navigate to thepentest/wireless/aircrack-ngdirectory. We now can execute aircrack-ng applications from anywhere in BackTrack!This can be a very useful technique for directories that we use often, but be careful to not add too many directories to your PATH variable as the system will have to search through every directory in the PATH to find commands and could potentially slow down your terminal and your hacking.That's It for Now...Stay tuned for more Linux basics for the aspiring hacker. If you haven't checked out the other guides yet, you can find them allright here. If you have any questions, make sure to comment below or start a thread in theNull Byte forumfor help.Want to start making money as a white hat hacker?Jump-start your hacking career with our2020 Premium Ethical Hacking Certification Training Bundlefrom the newNull Byte Shopand get over 60 hours of training from cybersecurity professionals.Buy Now (90% off) >Other worthwhile deals to check out:97% off The Ultimate 2021 White Hat Hacker Certification Bundle99% off The 2021 All-in-One Data Scientist Mega Bundle98% off The 2021 Premium Learn To Code Certification Bundle62% off MindMaster Mind Mapping Software: Perpetual LicenseCalm penguinandscreaming penguinphotos via ShutterstockRelatedNews:How to Study for the White Hat Hacker Associate Certification (CWA)Hack Like a Pro:Linux Basics for the Aspiring Hacker, Part 11 (Apache Web Servers)Hack Like a Pro:Linux Basics for the Aspiring Hacker, Part 4 (Finding Files)How To:The Essential Skills to Becoming a Master HackerHack Like a Pro:Linux Basics for the Aspiring Hacker, Part 22 (Samba)Hack Like a Pro:Linux Basics for the Aspiring Hacker, Part 6 (Networking Basics)Hack Like a Pro:Linux Basics for the Aspiring Hacker, Part 1 (Getting Started)Hack Like a Pro:Linux Basics for the Aspiring Hacker, Part 12 (Loadable Kernel Modules)Hack Like a Pro:Perl Scripting for the Aspiring Hacker, Part 1Hack Like a Pro:Metasploit for the Aspiring Hacker, Part 2 (Keywords)How to Hack Like a Pro:Getting Started with MetasploitHack Like a Pro:Linux Basics for the Aspiring Hacker, Part 13 (Mounting Drives & Devices)How To:Perl for the Aspiring Hacker - Part 1 - VariablesHack Like a Pro:Linux Basics for the Aspiring Hacker, Part 2 (Creating Directories & Files)Hack Like a Pro:Linux Basics for the Aspiring Hacker, Part 25 (Inetd, the Super Daemon)Hack Like a Pro:Linux Basics for the Aspiring Hacker, Part 21 (GRUB Bootloader)Hack Like a Pro:Python Scripting for the Aspiring Hacker, Part 2Hack Like a Pro:Scripting for the Aspiring Hacker, Part 1 (BASH Basics)Hack Like a Pro:Python Scripting for the Aspiring Hacker, Part 1Hack Like a Pro:Linux Basics for the Aspiring Hacker, Part 17 (Client DNS)Hack Like a Pro:Linux Basics for the Aspiring Hacker, Part 5 (Installing New Software)How To:Linux Basics for the Aspiring Hacker: Managing Hard DrivesHow To:Linux Basics for the Aspiring Hacker: Configuring ApacheGoodnight Byte:HackThisSite Walkthrough, Part 6 - Legal Hacker TrainingGoodnight Byte:HackThisSite Walkthrough, Part 8 - Legal Hacker TrainingCommunity Byte:HackThisSite Walkthrough, Part 6 - Legal Hacker TrainingCommunity Byte:HackThisSite Walkthrough, Part 1 - Legal Hacker TrainingScrabble Bingo of the Day:EURYOKYCommunity Byte:HackThisSite Walkthrough, Part 2 - Legal Hacker TrainingHack Like a Pro:Hacking Samba on Ubuntu and Installing the MeterpreterGoodnight Byte:HackThisSite Walkthrough, Part 10 - Legal Hacker TrainingGoodnight Byte:HackThisSite Walkthrough, Part 9 - Legal Hacker TrainingGoodnight Byte:HackThisSite Walkthrough, Part 4 - Legal Hacker TrainingNews:Let Me Introduce MyselfCommunity Byte:HackThisSite Walkthrough, Part 10 - Legal Hacker TrainingHow To:How Hackers Take Your Encrypted Passwords & Crack ThemNews:Complete Arch Linux Installation, Part 2: Graphical User Interface & Packages