Most Useful Linux Commands

Coding

list files in a directory (with details)

ls -la

directory usage (show memory usage of a dir recursively, in MB)

du -s

copy one directory to another

cp /home/userone/myproject /home/user1/mybackup

copy one directory to another and always overwrite

yes | cp -rf /etc/myproject /etc/mybackup

create multiple directories in one go

mkdir -p /etc/{public,private,log,backup}

find all zip files and print their path on screen

find . -name “*.zip” -print

zip a complete directory into a zip file

zip -r archivefile1 .

import a mysql db from gzip in one go

gunzip < file.gz | mysql -u root -p dbname

export a mysql db to gzip file in one go

mysqldump –opt -uUSER -pPASSWORD DATABASE | gzip > /server/path/database.sql.gz

get latest wordpress version from SVN into current folder (don’t omit the period “.” at the end)

svn export http://core.svn.wordpress.org/tags/3.4.2 .

find running process and kill it (don’t try to shut off ps or bash)

ps
kill -9 [pid]

show free memory in MB

free -m

show file usage per filesystem in GB

df -h

show all running processes (press ctrl + c to get out of it)

top

make folder (and subfolders) public/writeable by all

sudo chmod -R 777 *

edit a file without going crazy

nano /etc/myfilename.cfg

This list will be continued as new common commands are found and used.

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.

Close