0% found this document useful (0 votes)
188 views3 pages

Linux Command Line Cheat Sheet for Web Devs

This document provides a cheat sheet of Linux command line shortcuts and commands useful for web developers. It includes sections on usage shortcuts, system commands, navigating directories, file transfer, searching, files and permissions, installations, and web developer administration. The cheat sheet lists over 50 common Linux commands and their basic usage.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
188 views3 pages

Linux Command Line Cheat Sheet for Web Devs

This document provides a cheat sheet of Linux command line shortcuts and commands useful for web developers. It includes sections on usage shortcuts, system commands, navigating directories, file transfer, searching, files and permissions, installations, and web developer administration. The cheat sheet lists over 50 common Linux commands and their basic usage.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Available from

Linux Command Line Cheat-sheet [Link]


for web-developers

Usage Shortcuts System Commands


 Press to see the previous command you typed. df Disk free space, eg: df -h
tab Press once to auto-complete file/directory names pwd Print working directory (your current location)
tab-tab Press twice to see a list of possible auto- users Print all users of the system
completions of file/directory names screen Resume terminal window on remote system Eg:
/ Root directory. Eg: cd / screen (initiate), screen -d (detach) screen -r
~ Home directory. Eg: cd ~ (reconnect) exit (exits a screen)
. Current directory Eg: cd ./images du Disk usage of any file or directory
.. Parent directory Eg: cd ../ Eg: du -ach images/ (a=all, c=total, h=human
readable)
ctrl a Moves cursor to beginning of line
/proc/meminfo Detect system RAM.
ctrl e Moves cursor to end of line
Eg: grep MemTotal /proc/meminfo
ctrl r Remember a command you typed earlier.
Eg: Ctrl r rsync (if you used rsync yesterday) /proc/cpuinfo Detect CPU information
ctrl c Forcefully end a process or task Eg: grep "model name" /proc/cpuinfo
ctrl d Gracefully end a process or task cron Scheduled tasks. Make a file to be executed, and
make a cron file in the following format:
help Get help with the program you are trying to run.
Eg: mkdir –help or mkdir –help or mkdir –h minute hour day(of month) month(1-12)
weekday(0-6) [Link]
or ftp [Link]
Eg: 0 1,2 * * * /[Link] Will run at 1and 2am
help
every night. Save this text file. Then run:
man See the user manual for the program you are cron [Link] (to install the
more View a file (linear read only, press spacebar to crontab)
progress) whereis Find a service, Eg: whereis mysql
Eg: more [Link]
alias Define shortcuts for long instructions:
less Like more but can navigate forward and backward Eg: alias ls='ls -F'
through the file (use spacebar to go forward, and b (will run ls –f every time you type ls). Or make a
to go backward) file containing all aliases called .bash_aliases

Navigating Directories File Transfer


cd Change Directory. wget Download public files from other servers.
Eg: cd /var/www/vhosts/[Link]/httpdocs Eg: wget [Link]
(to navigate to your website files)
Download whole website:
ls List all files and directories in the current directory
Eg: wget -r -l 0 [Link]
ls -al List all files and directories, with more information
Download title page, images, css and make local
(or ll)
references:
ls –lSr List files biggest first Eg: wget -p -k [Link]
ls with grep Filter the result set based on search: ftp Eg: ftp [Link]
Eg: ls -l grep *.php myUserName
Or: ls grep index* myPassword
mkdir Make a directory Eg: mkdir myFolder cd /var/www/toToYourPreferredDirectory
rm Remove File or Directory. lcd c:\temp\gotoYourPreferredLocalDirectory
Eg: rm myFolder (if empty) get [Link] (upload this file)
Eg: rm myFolder –fr (if not empty and has sub- put [Link] (download a file)
directories, f=force, r=recursive) ssh/scp Connect via SSH, then do secure copy transfer:
unlink Delete a file. Eg: unlink myFolder/[Link] or ssh root@[Link]
unlink [Link]
e.g. scp [Link] /putFilesHere or
cp Copy a file. scp /getFileFromHere [Link]/
Eg: cp [Link] myFolder/[Link]
(takes format of from then to) rsync Download files from one machine to another by
SSH login to remote machine.
mv Moves a file
Eg: mv [Link] myFolder/[Link] Eg: rsync -e ssh -avz
user@[Link]:/var/www/html
Searching Files & Permissions
find Find files. Eg: find [Link] chmod Change mode of a file or directory.
locate Find files on the system (only includes files present Eg: chmod 777 [Link]
last time updatedb was run. Should be set as daily chown Change the owner of a file or directory.
cron job). Eg: chown root [Link] or
chown –R root myDir/ (R=recursive)
chgrp Change the group-ownership of a file or directory.
Installations
Eg: chgrp root [Link] or
.\ configure Configure the program before installation to chgrp –R root myDir/
identify any dependencies
Rename for old in *.php3; do cp $old `basename $old
make install Install the program, and delete the installation multiple files’ .php3`.php; unlink $old; done
make clean files when complete extensions or Eg: rename php3 php *.php3 (rename all php3
rpm Install an rpm (packaged program) for your OS and files to php in anyfile matching *.php3)
hardware.
Eg: rpm –ivh packagename (to install an RPM)
Eg: rpm –Uvh packagename (to upgrade an RPM) Compression & Archives
Eg: rpm -q -a (to see all installed RPMs) tar Make or Extract tar files.
Eg: tar –xvf [Link] (extract)
which Identify the executable file in a directory
Eg: tar -cvf [Link] images/ (make a tar file out
Eg: which ./
of your images directory)
Eg: tar –czvf [Link] directory/ (make .[Link])
Web Developer Administration Eg: tar –cjvf [Link] directory/ (make .[Link])
service Restart Apache, eg: service httpd restartRestart bzip2 Compress/Decompress files using bzip
MySQL, eg: service mysql restart Eg: bzip2 [Link] (compresses the tar file you just
mysql Repair DB. Eg:/usr/bin/mysqlcheck -A -p –repair made into [Link])
Backup DB: /usr/bin/mysqldump -B myDB-u Eg: bunzip2 [Link] (decompresses the file
myusername -p > myDB_backup.sql again)
Restore DB: cd usr/bin/ ./mysqldump -B myDB -u zip Compress/Decompress files using zip
myusername -p < myDB_backup.sql Eg: zip –r myzipfile images (to make [Link]
php Output phpinfo() Eg: php -i from the images folder) or zip –r myZip .* * (zip
Find [Link] file: whole dir)
Eg: locate [Link] or Eg: php -i grep [Link] Eg: unzip myZip (to unzip the [Link] file into
ftp Add FTP user, Eg: the current dir)
adduser newUsername
then
passwd newUsername
DNS & Networking
host Get information about a domain name or ip
Delete FTP user, eg: userdel -r newUsername host –mx Lookup the MX records for a domain or ip
netstat Print network connections and routing tables
ping Ping [Link] or ping [Link]
Vi – Text Editor
traceroute traceroute [Link]
open Load a file into vi. Eg: vi [Link]
whois whois [Link]
close Hit Esc. Press :q (do use the colon)
Flush DNS To flush the DNS settings,
save and close Hit Esc. Press ZZ or :q (and follow warning)
use:/etc/rc.d/init.d/nscd restart
exit without Hit Esc. Press :q!
nslookup See DNS configuration of your system.
save
Eg: nslookupset type=mx
save as… Hit Esc. Press :w [Link]
[Link] (to look up mx records)
edit file Type a or I to enter edit mode.
or
undo u
set type=a
search / (search downward)
[Link] (to look up a name records)
? (search upward)
Escape the following characters with \ if used in a ifconfig Get your ip addresses
search: ^ * . $ [ > < Eg: /sbin/ifconfig
/code (find the word code)
n (next occurrence)
N (previous occurrence)

You might also like