Search This Blog

Sunday, 5 October 2014

Directory commands

Common Directory Commands
To Change the working Directory.
cd /etl/IS/Path

It is used to move the control from current directory to the specified directory.
Other commands related to cd:
cd .. Go to Parent Directory
cd . Go to Current Directory
pwd Prints the path of current working directory

To create a directory using mkdir
mkdir -p dir1/dir2/dir3
This command is used to create a directory or a hierarchical directory.
To remove a directory using  rmdir(if its empty):
rmdir /home/ankit/aaa
To remove a directory if its not empty:
rm -rf /home/ankit/aaa
It delete all files and folders contains in aaa directory

To  move a directory using  MVDIR:
mvdir /home/ankit/aaa /desk/ankit/aaa
mvdir moves one directory tree into another existing directory or renames a directory without moving it

To list the files and folders in a particular directory using ls
ls path
ls /etl/IS/folder/temp

ls command lists all the files, folders inside the directory.  Other commands are as below

Command
Purpose
ls -l
long format, displaying Unix file types, permissions, number of hard links, owner, group, size, last-modified date and filename
ls -f
Do not sort. Useful for directories containing large numbers of files.
ls -F
Appends a character revealing the nature of a file, for example, * for an executable, or / for a directory. Regular files have no suffix.
ls -a
Lists all files in the given directory, including those whose names start with "." (which are hidden files in Unix).
ls -R
Recursively lists subdirectories. The command ls -R / would therefore list all files.
ls -d
Shows information about a symbolic link or directory, rather than about the link's target or listing the contents of a directory.
ls -t
Sort the list of files by modification time.
ls -h
Print sizes in human readable format. (e.g., 1K, 234M, 2G, etc.)
   ls -d */
Lists the directories in a path


No comments:

Post a Comment