Linux

Frequently Used Linux / Unix Commands

Today’s *nix systems usually comes with a nice enough UI to handle things like copy/paste, find, find in files, directory space usage etc. however, there are times when you need to stay at the command prompt or shell. Remembering the commands with pipes and forks can be daunting – and very frustrating. Below is a raw list of the top commands used by me when using shell into my Linode accounts. Use your own good judgment when running these. Run as root or use “sudo” before all the commands below.

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.

Related Posts

  • No Related Posts

Related Posts

  • No Related Posts