Wednesday, August 6, 2008

Files and Directory Related Commands

cd /home enter to directory '/ home'
cd .. go back one level
cd ../.. go back two levels
cd go to home directory
cd ~user1 go to home directory
cd - go to previous directory
pwd show the path of work directory
ls view files of directory
ls -F view files of directory
ls -l show details of files and directory
ls -a show hidden files
ls *[0-9]* show files and directory containing numbers
tree show files and directories in a tree starting from root(1)
lstree show files and directories in a tree starting from root(2)
mkdir dir1 create a directory called 'dir1'
mkdir dir1 dir2 create two directories simultaneously
mkdir -p /tmp/dir1/dir2 create a directory tree
rm -f file1 delete file called 'file1'
rmdir dir1 delete directory called 'dir1'
rm -rf dir1 remove a directory called 'dir1' and contents recursively
rm -rf dir1 dir2 remove two directories and their contents recursively
mv dir1 new_dir rename / move a file or directory
cp file1 file2 copying a file
cp dir/* . copy all files of a directory within the current work directory
cp -a /tmp/dir1 . copy a directory within the current work directory
cp -a dir1 dir2 copy a directory
ln -s file1 lnk1 create a symbolic link to file or directory
ln file1 lnk1 create a physical link to file or directory
touch -t 0712250000 file1 modify timestamp of a file or directory - (YYMMDDhhmm)
file file1 outputs the mime type of the file as text
iconv -l lists known encodings
iconv -f fromEncoding -t toEncoding inputFile > outputFile creates a new from the given input file by assuming it is encoded in fromEncoding and converting it to toEncoding.
find . -maxdepth 1 -name \*.jpg -print -exec convert "{}" -resize 80x60 "thumbs/{}" \; batch resize files in the current directory and send them to a thumbnails directory (requires convert from Imagemagick)

Source: LinuxGuide.it

Keep Smiling..:)

No comments: