Common Linux Shell Command Reference Print

  • 778

If you want to copy all the files and folders from /path/folder/ to /other_path/folder/ you would...

Move to the Source Folder

 

cd /path/folder/

Copy All Files from Current Folder to Destination Folder

 

cp -R * /path/destination/folder/

Mount New Disk

 

  1. Create Folder to Mount Too

    mkdir /path/folder
    ie: mkdir /media/disk1

  2. Mount the Disk

    mount -t {file-system-type} /disk/id /media/disk1

    -t indicates the type of file system - vfat = FAT32
    /disk/id indicates the disk identification - this can be attained by typing "fdisk -l" to list all available disks

Basic Directory Operations

 

  • List Directory Contents

    ls -al

  • Change Directory

    cd dirname

  • Make Directory

    mkdir dirname

  • Remove Directory (and all contents)

    rmdir dirname -Rf

Create TAR.GZ Gzip Compressed Tarball Files (For BACKUP, STORAGE, or TRANSFER)

 

  • Create TAR.GZ of all folder contents

    tar -czvf filename.tar.gz .
    -or- 
    tar cvf - . | gzip > filename.tar.gz

  • Create TAR.GZ of just JPG images (for example)

    tar -czvf filename.tar.gz *.jpg
    -or- 
    tar cvf - *.jpg | gzip > filename.tar.gz

  • Extract TAR.GZ contents (into current folder)

    tar -xzvf filename.tar.gz
    -or
    tar xvfz filename.tar.gz

How to Recursively CHMOD Files and Folders

 

  • Recursively CHMOD Folders Only

    find . -type d -exec chmod 755 {} \;
  • Recursively CHMOD Files Only

    find . -type f -exec chmod 644 {} \;

 

 


Was this answer helpful?

« Back