Loading

Thursday, July 23, 2009

Linux Crib Sheet for commands

DIRECTORY NAVIGATION AND BROWSING
=======================================
Working directory: pwd
List files (dir): ls -alh

Changing owner to ‘testuser’ in ‘testgroup’: chown testuser.testgroup #FILENAME#
Changing permission to rwxrw-r-- for a file: chmod 764 #FILENAME#

List the contents of a text file: cat
Example – listing contents of ‘hosts’ (used for local name resolution): cat /etc/hosts
Example – list contents of ‘resolv.conf’ (used for DNS name resolution): cat /etc/resolv.conf


PROCESS MANAGEMENT
=======================================
View performance metrics: top
List running processes: ps –ef ps –aux
Kill a process: kill #PID# -9


DISK MANAGEMENT
=======================================
Determine free disk space: df –h
Determine space used by current directory: du -sh
Determine space used by current directory w/ subs broken out: du -sh *


VERSION
========================================
Determining version of Linux: cat /etc/*release
Determining kernel version of Linux: uname –a


COPY FILE PRESERVING FILENAME
========================================
cp -p /path/to/sourcefile.name /path/to/targetfile.name


FIND COMMAND
========================================
find /home/httpd/vhosts/YOURdomaincom/httpdocs/outpost/ -mtime -300 -print
(finds all files of regular type that were modified in last 300 days in that DIRECTORY)

find . -mtime -1 -print
(finds all files in current directory folder modified in the last day)

find / -size +10240000c -exec du -h {} \;
(shows all files under root that exceed 10mb)

No comments:

Post a Comment