You need to use “ls -la” to list the hidden files in your home (i.e ~) directory. These config files are “.bashrc”, “.inputrc”, “.profile”, etc. In computing, a hidden folder or hidden file is a folder or file that does not display by default when showing a directory/file listing. In Unix-like operating systems, any file or folder that starts with a dot character is to be treated as hidden. The ls command does not display them unless the -a flag (ls -a) is used.
Q1. What is a .bashrc file?
A1. .bashrc is a shell script that Bash runs whenever it is started interactively. You can put any command in that file that you could type at the command prompt.
1 2 3 4 5 6 7 8 9 10 11 12 |
# examples export HOMEDIR=/cygdrive/c/Users/john export SVN_EDITOR=vim export TERM=xterm export PS1='\[\e]0;\W\a\]\[\e[32m\]\u@\h \[\e[33m\]\W\[\e[0m\]\$ ' export JAVA_HOME=/cygdrive/c/TOOLS/java/jdk1.7.0_40 export MAVEN_HOME=/cygdrive/c/TOOLS/maven/apache-maven-3.1.0 export MAVEN_OPTS="-Xms64m -Xmx512m -XX:MaxPermSize=256m" export PATH=$JAVA_HOME/bin:$MAVEN_HOME/bin:~/bin:$PATH export JBOSS_HOME=/cygdrive/c/TOOLS/jboss-eap-5.1.1/jboss-as export WL_HOME=/cygdrive/c/Tools/weblogic/weblogic-10.3.5.0/wlserver_10.3 |
Q2. Once you make a change to .bashrc file, how do you ensure that the changes take effect in the session you are running?
A2. tun the source command.
1 |
source .bashrc |
Q3. What is a .inputrc file?
A3. The .inputrc file handles keyboard mapping for specific situations.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
# VT "\e[1~": beginning-of-line "\e[4~": end-of-line # kvt "\e[H": beginning-of-line "\e[F": end-of-line # rxvt and konsole (i.e. the KDE-app...) "\e[7~": beginning-of-line "\e[8~": end-of-line # VT220 "\eOH": beginning-of-line "\eOF": end-of-line |
Q4. What is a .bash_history file?
A4. History is maintained both in a file .bash_history and in ram. This history can be manipulated with the command history command.
Q5. What is the difference between .profile and .bashrc?
A5.
config files read by “login” shells: E.g. when you login from another host, or login at the text console of a local unix machine. The config files are .login or .profile or .zlogin
config files that are read by “interactive” shells: Cygwin, etc. The config files are .bashrc, .tcshrc, .zshrc
So, you might have a .profile or .bash_profile file invoking the .bashrc
1 2 3 4 |
# source the users bashrc if it exists if [ -f "${HOME}/.bashrc" ] ; then source "${HOME}/.bashrc" fi |
Q6. Can you list some other hidden files from your experience?
A6. Git, SVN, Eclipse, etc use hidden files as the meta data
.gitignore or .svnignore
The files that are not checked into a source control system like Git or Subversion
1 2 3 4 |
.settings .project .classpath |
.svn or .git/config
The meta data files for source control systems like Subversion and Git. For example, in Git
1 2 |
cd .git # change directory to cat config |
You can see the origin, master, and branch details.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
[core] repositoryformatversion = 0 filemode = true bare = false logallrefupdates = true ignorecase = true [remote "origin"] fetch = +refs/heads/*:refs/remotes/origin/* url = ssh://git@stash.internal.myhost.com [branch "master"] remote = origin merge = refs/heads/master rebase = true [branch "myapp-integration"] remote = origin merge = refs/heads/myapp-integration rebase = true [branch "bugfix/ISSUE-161"] remote = origin merge = refs/heads/bugfix/ISSUE-161 rebase = true |
.settings, .classpath and .project
are eclipse IDE meta data files. For example, the “.classpath” file
1 2 3 4 5 6 7 |
<?xml version="1.0" encoding="UTF-8"?> <classpath> <classpathentry kind="src" path="src/main/java" including="**/*.java"/> <classpathentry kind="src" path="src/main/resources" excluding="**/*.java"/> <classpathentry kind="output" path="target/classes"/> <classpathentry kind="var" path="M2_REPO/junit/junit/3.8.1/junit-3.8.1.jar"/> </classpath> |
Q7. How do you make a file hidden in Java?
A7.
In Unix
The file or foldername must start with a dot (i.e. .bashrc, .git/config, etc)
In Dos
In Java 7 or later
1 2 |
Files.setAttribute(path, "dos:hidden", true); |
In Java 6 or older
1 2 3 |
Process p = Runtime.getRuntime().exec("attrib +H " + file.getPath()); p.waitFor(); |