Remember the days of DOS when you would go into your C:\ > root directory and EDIT C:\CONFIG.SYS file to enable or disable certain features of your software? Did you ever EDIT C:\AUTOEXEC.BAT to make a fancy prompt? The latest non-Linux operating system still has access to a “terminal” where you can type commands at the prompt, but the CONFIG.SYS and AUTOEXEC.BAT days are over. Unless of course you run LINUX!
The /etc directory in Linux is a root user controlled directory where common text files control your computer and the software it is running. There are a number of editors available for your use. My favorite editor is gedit (Yea, I know, the REAL UNIX men use vi). The gedit software means Gnome Editor. If you are already running the Gnome desktop it is installed by default. If you are running the KDE desktop (my favorite), you can use kword.
EXERCISE: Place the Konsole (Terminal) Icon on your desktop and on your menu bar.
Click the “Menu (K or Gnome Foot)” , Hover over “Tools”, Right Click on “Konsole”, Click on “Add item to Desk Top”. DONE. Sort of like the “other” operating system huh!
Let’s do it again.
Click the “Menu (K or Gnome Foot)” , Hover over “Tools”, Right Click on “Konsole”, Click on “Add item to Main Panel”. DONE.
EXERCISE: sort your desktop icons.
OK, you didn’t like where your Konsole icon was placed. Lets fix that.
RIGHT CLICK anywhere on your desktop. Hover over “Icons”, Hover over “Sort Icons” , CLICK on the sort method your want. DONE.
EXERCISE: Access the Konsole (Terminal), look around in /etc as joe user, and load a file in gedit (kwrite). Oh yea, remember those REM commands in DOS? It means REMARK and tells the terminal to ignore the statement. In the Bash Terminal the pound sign (#) does the same thing. It can also be used within a line to tell the interpreter to ignore everything on that line that follows the pound sign.
Click Konsole. You should see a DOS like screen with a dollar sign ($) prompt. If you see a pound sign prompt (#) that means you are logged in as root. Type exit and press {ENTER} key. You should see a dollar sign ($) prompt.
$ pwd {ENTER} # This means “print working directory” shows you where you are located.
/home/user/
$ ls {ENTER} # gives you a listing of what is in directory /home/user/
$ cd /etc {ENTER} # takes you to the /etc directory
$ pwd {ENTER} # shows you where you are at
/etc
$ ls {ENTER} # lists the stuff in /etc directory – look for a file called bashrc. Lots of stuff huh?
$ ls bash* {ENTER} # You will see a file bashrc and a bash directory.
$ gedit bashrc {ENTER} # You will see what this configuration file looks like that controls the terminal settings. We will work more with this file later. Try to change something in the file – you will not be able to change the file or save it because you are not root user. Exit out of gedit, you will be returned to the dollar sign prompt.
$ cd ~ {ENTER} # This takes you back to your home directory.
$ pwd {ENTER} # Verify you are home.
/home/user
$ exit {ENTER} # This closes your terminal. We are DONE.
EXERCISE: Modify your /etc/bashrc configuration file.
First, download the Superwhamadyne bashrc file. This file creates some useful Aliases that mimic DOS commands and creates a pretty prompt for you. It will probably download to your Downloads or Desktop directories.
In order to change anything in the /etc directory, you must be logged in as root user.
By now you remember how to get to the terminal right? Open the terminal
$ pwd {ENTER} # to find out where you are at. Tired of doing this? OK, we will fix it.
$ su root {ENTER} # this command switches user. If you wanted to switch user to mary, you would type su mary {ENTER}, but we want to switch user to root. Actually, if you simply type su {ENTER} it is the same as typing su root {ENTER}.
password: myrootpassword {ENTER} # Enter your root password that you set up when you first installed Linux.
# # Note the pound sign prompt – it means you are root user. You now have the authority to trash your computer!
# pwd ; print working directory to see where you are at.
# cp /etc/bashrc bashrc.000 {ENTER} # remember that file we looked at previously? We are going to make a copy (cp) of the original file so we can recover in case we make a serious misteake. Notice that we do not need to actually be IN the directory to make changes there.
# ls /etc/bash* # We are going to look for files named bash. See your new bashrc.000 file?
bashrc bashrc.000 bashdirectory
# cd /etc {ENTER} # change directory to /etc
# cp fstab fstab.000 {ENTER} # lets make a backup copy of the fstab file while we are at it.
# pwd {ENTER} # make sure of where we are at.
# cp /home/user/Downloads/bashrc . # user is you – your home directory. The dot following bashrc means copy the bashrc file from your Downloads directory and and place it here.
cp: overwrite ‘bashrc’? y {ENTER} # This is why we made the backup.
# exit {ENTER} # takes you back to your user prompt
$ exit {ENTER} # closes your terminal session.
Bash shell (the terminal) only reads the config file (bashrc) when it first starts. So, let’s start a new terminal session.
$ # # HEY NOW, AIN’T THAT PRETTY? (In case something is scrambled, log in as root and type # cp /etc/bashrc.000 bashrc). Now you also have DOS commands at your fingertips.
$ alias xcopy {ENTER} # remember that great DOS command, xcopy?
alias: xcopy=’ cp -ipdRuv’ # this shows you what linux switches (-ipdRuv) need to be used with cp (copy) to enable cp to mimic the DOS xcopy command. That new bashrc configuration file creates that alias.
$ alias md {ENTER}
alias: md=” mkdir’ # mkdir is the Linux command to make a directory. Typing md calls the command mkdir.
$ md ~/mytempdir {ENTER} # The tilde (~) says use the /home/user/ directory.
$ dir ~ {ENTER} # Ain’t that pretty! See your mytempdir?
$ xcopy ~/Desktop ~/mytempdir {ENTER} # copies everything from your Desktop directory and places it into your mytempdir, including subdirectories and hidden files.
$ dir ~/mytempdir {ENTER} # nifty huh?
$ cd ~/ {ENTER} # let’s go to the top of your user directory.
$ dir {ENTER}
$ cd myt{TAB} # notice how Linux can save you some work
$ cd De{TAB} # notice that if you don’t put ~ in your command, the current directory will be used which is shown for you by your pretty prompt on the line above.
$ dir {ENTER} # again, by not telling the command which directory to use, it operates on the current directory.
$ cd .. {ENTER} # the dots (..) like in DOS these dots say go back to the previous directory.
$ cd .. {ENTER} # you should be back in your /home/user/ directory. Let’s make sure.
$ cd ~/ {ENTER} # yep, you are at your /home/user/ directory.
# NOW, Lets look at another alias (this one can be very DANGEROUS!)
$ alias nuke {ENTER} # This command is designed to strike a portion of your hard drive with a nuclear weapon. Know what you are doing and be VERY CAREFUL. There is no way to un-nuke a nuked directory.
alias: nuke=’ rm -irf’ # rm means remove. i means info (unfortunately this happens so fast you wont get to watch the mushroom cloud), r means recursive (act on the main directory and any subdirectories), f means force (usually rm doesn’t want to remove directories). You have just given a non retractable order!
$ nuke mytempdir {ENTER}
$ dir {ENTER} # Where is mytempdir? It is gone for good and everything in it.
$ exit {ENTER} # close terminal – DONE.
2Tim. 2:15. Study to shew thyself approved unto God, a workman that needeth not to be ashamed, rightly dividing the word of truth.