Usefull Linux commands I can never seem to remember

This is just an ongoing list of Linux commands I keep having to lookup. I’ll be updating this list as things come up.

Compress & uncompress (tar.gz) a directory
Compress: tar -zcvf archive-name.tar.gz directory-name
Uncompress: tar -zxvf archive-name.tar.gz

Return Path for all directories of a given name (directory search)
find / -type d -name ‘DIRECTORYNAME’ -ls

File which specifies a servers root http path
/etc/httpd/conf/httpd.conf
Restart after making changes by running: /etc/init.d/httpd restart

Count number of files in a directory
cd to the directory
ls -1U */ | wc -l

Check directory size
du DIRECTORY
result is in KB

Copy a file from one machine to another
scp -P MACHINE_PORT_NUMBER -p FILE_TO_BE_COPIED USERNAME@MACHINE_IP:NEW_LOACTION
example: scp -P 22 -p file.php admin@255.255.255.255:/home/admin

Leave a comment