algorithms (22) Design Patterns (20) java (19) linux (14) Snippet (13) service mix (6) soa (4)



Linux Files and Directories

input----> Command ----> Output

input redirection <

output redirection >

cat f1 > f2

to concatenate

to display file contents

copy files

cat without any arguments ….takes from the terminal and writes to the terminal so reads from keyboard and displays on screen this will be infinite loop .

cat f1 >> f2  [APPEND]


read from standard input and show page by page on standard output.


  • is a easy way to create a file which does not exist
  • if it exists its access time is updated unlike cat it does not display

ls- lists the files/directories in a directory

  1. color has a meaning which can be found out using –color option.
  2. files starting with [.]DOT are hidden files.



/[Slash]- Root directory

dev: all devices

lib: library's for every one.

lost+found: specific to redhat recovered files

Misc: miscellaneous.

proc: mapping to memory.

tmp : temporary files

var : variety of log files

bin: binaries of commands like ls mkdir etc.

boot: boot loader files, kernel etc

sbin: system binaries

mnt: any mountable devices like cdrom pendrive are mounted under this.

./ : current working directory

..  : parent directory

: Home directory (available only in few shells)

PWD : print working directory

CD: change directory, cd without any arguments takes to the home directory

        to go to home u can  use cd $HOME , cd ~ or just cd.

mkdir:  <dir name …..>make a directory, on success does not give any message ,, instead u can use –V for verbose.

mkdir –p make parents as necessary.

rmdir <dir name ….> removes the specific dir

ls *:  all the files

ls f?: list files which start with f and have one more leter.

ls f[1234]/ls f[1-4]: f followed by one of 1-4

Note for copy and move

  • Use option -i to make it interactive along with v so that you have a say whether you have to overwrite or not .
  • use -r to move or copy recursively.
  • use –v to make it verbose.
  • -f to make it silent.
  • -b to take a back up before overwrite as we have bvf option is safest.


cp <source file> <dest file>     

cp <source files…….> <dest file>


mv <source file> <dest file>

mv <source files…….> <dest file>


rm: removes files completely very hard to recover.

rm –rf ~ [ most dangerous command ]

No comments:

Post a Comment

Search 24 Bytes