Linux - Directory Commands
mkdir The mkdir command creates new directories in your file system.  mkdir myfiles  Creates a new directory called myfiles whose parent is the current directory.  mkdir --version  mkdir --help  mkdir ~/myfiles  Create the directory myfiles in your home directory, specified here with a tilde ("~")
 mkdir -m a=rwx mydir  Create the mydir directory, and set its file mode (-m) so that all users (a) may read (r), write (w), and execute (x) it.  mkdir -p /home/hope/Documents/pdf  Creates the directory /home/hope/Documents/pdf. If any of the parent directories /home, /home/hope, or /home/hope/Documents do not already exist, they will automatically be created.  mkdir -p /home/test/test1/test2/test3/test4  to create several subdirectories at one time  mkdir test1 test2 test3  to create multiple directories at one time
Output
Output
rmdir  rmdir — The rmdir command removes a directory from your filesystem.  rmdir mydir
cd  The cd command, which stands for "change directory", changes the shell's current working directory.  By default, when you open a terminal and begin using the command line, you are placed in your home directory.  All files and directories on your system stem from one main directory: the root directory.  Any directory contained inside another directory is called a subdirectory.
 cd /documents/work/accounting  To change into this directory, making it our working directory  cd /  To change into the root directory, making it our working directory  cd .  The current directory, regardless of which directory it is, is represented by a single dot (".").  cd ~  Change to home directory. Your home directory is the directory you're placed in, by default, when you open a new terminal session  cd  Change to home directory  cd ..
 cd documents  cd ./documents  cd documents/.  cd ./documents/.  cd /documents/work/accounting  To change into this directory, making it our working directory
Output
ls  ls  ls /  List root directory  ls ..  List parent directory  ls ~  List user's home directory   ls -l  List with long format  ls -a  Show hidden files  ls -t  Sort by date/time
 ls -S  Sort by file size  ls *  List all subdirectories  ls -R  Recursive directory tree list  ls *.txt  List only text files with wildcard  ls > out.txt  ls redirection to output file  ls -d */  List directories only  ls -d $PWD/*  List files and directories with full path
Output
output
Output
 ls -p  Puts / at the end of the directory  ls -u  -lists in the order of access time  ls -i  Display inode infm (index no)  ls -ltr  Lists files order by date  ls -lSr  Lists files order by file size
Linux - Directory commands
Linux - Directory commands
Linux - Directory commands

Linux - Directory commands

  • 1.
  • 2.
    mkdir The mkdir commandcreates new directories in your file system.  mkdir myfiles  Creates a new directory called myfiles whose parent is the current directory.  mkdir --version  mkdir --help  mkdir ~/myfiles  Create the directory myfiles in your home directory, specified here with a tilde ("~")
  • 3.
     mkdir -ma=rwx mydir  Create the mydir directory, and set its file mode (-m) so that all users (a) may read (r), write (w), and execute (x) it.  mkdir -p /home/hope/Documents/pdf  Creates the directory /home/hope/Documents/pdf. If any of the parent directories /home, /home/hope, or /home/hope/Documents do not already exist, they will automatically be created.  mkdir -p /home/test/test1/test2/test3/test4  to create several subdirectories at one time  mkdir test1 test2 test3  to create multiple directories at one time
  • 4.
  • 5.
  • 6.
    rmdir  rmdir —The rmdir command removes a directory from your filesystem.  rmdir mydir
  • 7.
    cd  The cdcommand, which stands for "change directory", changes the shell's current working directory.  By default, when you open a terminal and begin using the command line, you are placed in your home directory.  All files and directories on your system stem from one main directory: the root directory.  Any directory contained inside another directory is called a subdirectory.
  • 8.
     cd /documents/work/accounting To change into this directory, making it our working directory  cd /  To change into the root directory, making it our working directory  cd .  The current directory, regardless of which directory it is, is represented by a single dot (".").  cd ~  Change to home directory. Your home directory is the directory you're placed in, by default, when you open a new terminal session  cd  Change to home directory  cd ..
  • 9.
     cd documents cd ./documents  cd documents/.  cd ./documents/.  cd /documents/work/accounting  To change into this directory, making it our working directory
  • 10.
  • 11.
    ls  ls  ls/  List root directory  ls ..  List parent directory  ls ~  List user's home directory   ls -l  List with long format  ls -a  Show hidden files  ls -t  Sort by date/time
  • 12.
     ls -S Sort by file size  ls *  List all subdirectories  ls -R  Recursive directory tree list  ls *.txt  List only text files with wildcard  ls > out.txt  ls redirection to output file  ls -d */  List directories only  ls -d $PWD/*  List files and directories with full path
  • 13.
  • 14.
  • 15.
  • 16.
     ls -p Puts / at the end of the directory  ls -u  -lists in the order of access time  ls -i  Display inode infm (index no)  ls -ltr  Lists files order by date  ls -lSr  Lists files order by file size