Hidden Files
Windows 2000

General Info

Roving Profile
Exam Papers

System Support


Linux: Hidden files

Before you start using Linux you should be aware of specific files that exist in your home directory. To view these files type
ls -a
Files that begin with "." are hidden files in Linux. You'll find a lot of files on the system that end in 'rc'. Those files allow you to configure a certain program to run just the way you like it. Probably one of the most important hidden files is ".bashrc". The .bashrc file among other functions, determines the behaviour of interactive shells. In your .bashrc file you place any shell commands that you want executed every time you start up a new shell. It is important to note that a student should be familiar with what they are doing before editing the .bashrc file. In fact a corrupt .bashrc file may prevent the user from logging in.

Editing .bashrc file

Introduction to Aliases:

In the .bashrc, you can add something called an 'alias'. Everybody knows what 'alias' means- 'an assumed name'. An 'alias' in this file are some lines that you write so that your bash shell assumes that one command is really a variation of it. As you already know, you can modify a command with a slash '-' and a letter. To see where the .bashrc file was, you could have typed 'ls -a' and that would have shown you every file in the directory, including those that start with '.' If you find yourself using these '-letter' combinations a lot, you can modify your .bashrc file so that even though you type the simple command, like 'ls', you actually get 'ls -a'. Some of these aliases may be very important to keep you from deleting that program that you just wrote into non-existence by accident. It would be advisable if students had some if not all of the following aliases in their .bashrc file.They are:

alias cp='cp -v -i'
alias rm='rm -i'
alias mv='mv -i'

'cp' is the command to copy a file to another place or to make a copy of a file under a different name. In order not to copy a file to a place where there's already a file by the same name, you could type cp -v -i, (-v for verbose, -i for interactive) and it would ask you if you really want to do it in case there's another file by the same name. Then the -v would show you where it went. This is probably a good idea all the time, so you could create an alias for it in your '.bashrc' file. 'rm' is the remove/delete command (i.e gone forever) You obviously have to be very careful with this one, because in the bash shell there is really no 'trash' bucket to pick it out of if you delete it. That's why you should add the -i (interactive) command to your alias, so that it will ask you if you really want to delete that program that you just wrote. 'mv' is for moving files to a different place or renaming a file. You should/will have an alias for it for the same reasons as the 'cp' command.

Changing the default prompt

To change the default primary prompt, you need to set the shell variable $PS1. To have this set every time you log in, you can put some commands in your .bash_profile which set this globally, or you can add the same lines to your .bashrc. Something like the following should work for bash: PS1='\h\w$ ' export PS1 $PS1 is the shell variable containing the primary prompt. As you will see shortly, it can contain all sorts of useful information. The \h\w bit gives you a prompt which tells you the machine's (h)ostname, and you current location in the (w)orking directory tree relative to your home directory. This gives you a prompt which looks like the following:
If you are still in your home directory. If you now type cd Mail (assuming you have a Mail directory) then you will see:
as your new prompt. If you do cd /share/bin (out of your home directory) then it will look like this:
And so on. If you don't want anything that fancy, just change the .bash_profile line to something like PS1='beetroot> 'or whatever takes your fancy. However 'beetroot' would be relatively meaningless. Instead, build a nice, compact yet informative prompt. Possible listings of the prompts are given below:

\a The ASCII bell character (you can also type \007)
\d Date in "Wed Sep 06" format
\e ASCII escape character (you can also type \033)
\h First part of hostname (such as "mybox")
\H The Full hostname (such as "")
\j The number of processes you've suspended in this shell by hitting ^Z
\l The name of the shell's terminal device (such as "ttyp4")
\n Newline
\r Carriage return
\s The name of the shell executable (such as "bash")
\t Time in 24-hour format (such as "23:01:01")
\T Time in 12-hour format (such as "11:01:01")
\@ Time in 12-hour format with am/pm
\u Username
\w Current working directory (such as "/techHandbook/home/drobbins")
\W The "basename" of the current working directory (such as "drobbins")
\! Current command's position in the history buffer
\# Command number (this will count up at each prompt, as long as you type something)
\$ If you are not root, inserts a "$"; if you are root, you get a "#"
\xxx Inserts an ASCII character based on three-digit number xxx (replace unused digits with zeros, such as "\007")
\\ Its a backslash

The .bash_logout file:

The .bash_logout file is read whenever you log out. If there are things you want to run whenever you log out, add lines here to start them---just as in any shell script.Comments can be added by preceding the line of text with a '#' sign.

The .bash_login file:

The .bash_login file is read whenever you log in assuming that bash is your shell. As you can see, everything here is commented out (with #). If there are things you want to run whenever you log in, add lines here to start them---just as in any shell script.

The .Xdefaults file:

The .Xdefaults file is a place to put your preferences about fonts, colours, and other attributes of applications running under the X window system. In the .Xdefaults file, you can for example specify the background and foreground colours of the xterm for you session. As with any of the hidden files on your home directory be sure to modify them only if you understand what you are doing.

Department of computer science and information systems
University of limerick, limerick, Eire

Department of Computer Science and Information Systems, University of Limerick, Limerick, Eire
Valid HTML 4.01! Valid CSS!