Knowledgebase
Portal Home > Knowledgebase > Linux / Apache Hosting > Common Linux Shell Command Reference
Common Linux Shell Command Reference
How to Copy Files from One Folder to Another in Linux / UnixIf 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
- Create Folder to Mount Too
mkdir /path/folder ie: mkdir /media/disk1
- 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 {} \;
How to Recursively Rename Files
- Recursively Rename
find . -name "*.EXTA" | sed 's:\(.*\)\.EXTA:mv "\1.EXTA" "\1.EXTB":' | sh
Where EXTA is the original file extension, and EXTB is the new file extension. This method uses Regular Expressions, and can be modified to perform any kind of filename substitution needed.
|
Also Read