Linux command guide: Difference between revisions

From ITCwiki
Jump to navigation Jump to search
No edit summary
No edit summary
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
== Contents ==
== Getting Help ==


'''man <command>''' – Display command help


1. Getting Help
'''man find | grep <search string>''' – Locate specific help text within the manual


2. Directory Navigation, basic shell tasks, and File Management
'''info''' – Provide man help in a different format


3. Redirection and Piping


4. Text Processing


5. Package Management
== Directory navigation, basic shell tasks, and File Management ==


6. Useful Management Commands
'''cd''' – Change working directory


7. Useful Configuration Files
'''cd ..''' – Change to parent directory


'''cd ~''' – Change to home working directory


1. Getting Help
'''pwd''' – Display working directory


man <command> – Display command help
'''echo <line of text>''' – Display the line of text (useful for user friendly scripting)


man find | grep <search string> Locate specific help text within the manual
'''echo $PATH''' Display assignment to the environmental variable


info – Provide man help in a different format
'''time <command>''' - Time how long <command> took to execute


'''ls''' – Lists files in the current working directory


2. Directory navigation, basic shell tasks, and File Management
'''ls -a''' –  Shows hidden files (hidden files start with a dot) as part of file listing


cd Change working directory
'''ls -l''' Shows file detail


cd .. Change to parent directory
'''ls –F''' Shows File type as part of file listing


cd ~ Change to home working directory
'''history''' Records commands typed at command prompt
    '''Ctrl+R''' to begin a backward search through history
    '''Ctrl+S''' to search forward through history
    '''Up Arrow''' and '''Down Arrow''' to move a line at a time through history


pwd Display working directory
'''mkdir ch1''' Creates new directory ch1


echo <line of text> Display the line of text (useful for user friendly scripting)
'''mv file1 file2''' Moves file file1 to file2, renames file1 to file2


echo $PATH – Display assignment to the environmental variable
'''mv testfile changedfile'''


time <command> - Time how long <command> took to execute
'''less''' – View file contents page-by-page


ls Lists files in the current working directory
'''unset MYNAME''' Removes the environment variable assignment assigned to MYNAME


ls -a Shows hidden files (hidden files start with a dot) as part of file listing
'''exit''' Terminate shell


ls -l Shows file detail
'''cp -R one newone''' Copies directory /one recursively to a new directory named /newone


ls –F Shows File type as part of file listing
'''rm etcbackup.tar.gz''' Deletes file


history – Records commands typed at command prompt


Ctrl+R to begin a backward search through history


Ctrl+S to search forward through history
== Redirection and piping ==
'''ls > List-of-files.txt''' – Write list of files in current working directory to the file, List-of-files.txt


Up Arrow and Down Arrow to move a line at a time through history
'''pwd >> List-of-files.txt''' – Append current working directory to the file “List-of-files.txt”


mkdir ch1 Creates new directory ch1
'''ps ax | grep string''' Pipe output of ps ax to grep which searches for string.


mv file1 file2 – Moves file file1 to file2, renames file1 to file2


mv testfile changedfile


less View file contents page-by-page
== Text processing commands ==
'''cat''' Concatenate files together


unset MYNAME Removes the environment variable assignment assigned to MYNAME
'''cat /proc/interrupts''' Display information from interrupts file (querying kernel about interrupts)


exit Terminate shell
'''join''' Merge file data from multiple files


cp -R one newone Copies directory /one recursively to a new directory named /newone
'''sort''' Sort file contents


rm etcbackup.tar.gz Deletes file
'''nl''' Generate line numbers for each line in a file


'''tail -20 /var/log/syslog''' – View last 20 entries posted to syslog file


3. Redirection and piping
'''less''' – File paging utility


ls > List-of-files.txt Write list of files in current working directory to the file, List-of-files.txt
'''grep string /var/log/*''' Search for all occurrences of string in all log files in /var/log directory


pwd >> List-of-files.txt – Append current working directory to the file “List-of-files.txt”


ps ax | grep string – Pipe output of ps ax to grep which searches for string.


== Package Management ==


4. Text processing commands
'''rpm Utility'''
    '''rpm -q zsh''' – Check if RPM package zsh (z shell) is installed
    '''rpm -i zsh-4.3.9-4.fc11.i586.rpm''' – Installs the zsh RPM package
    '''remove zsh: rpm -e zsh''' – Uninstalls the zsh RPM package


cat Concatenate files together
'''yum Utility'''
    '''yum install zsh''' Downloads and installs zsh package


cat /proc/interrupts Display information from interrupts file (querying kernel about interrupts)
'''apt-get Utility'''
    '''sudo apt-get install alien''' Downloads and installs the program “alien”
    '''sudo apt-get install chkconfig''' – Downloads and installs the program “chkconfig”
    '''sudo apt-get remove package''' – Remove package
    '''sudo apt-get install sysv-rc-conf''' - Provides gui view of all services running at each runlevel (works under server)
    '''apt-get autoremove''' – Removes additional programs associated with the main package installation


join – Merge file data from multiple files


sort Sort file contents
'''ldd /bin/ls''' Display information about libraries used by the ls program


nl – Generate line numbers for each line in a file


tail -20 /var/log/syslog – View last 20 entries posted to syslog file


less – File paging utility
== Useful Management Commands ==


grep string /var/log/* Search for all occurrences of string in all log files in /var/log directory
'''ps aux''' –  


'''top''' –


5. Package Management
'''kill pid''' – Send kill signal to process (pid)


rpm Utility
'''jobs''' – List all currently running jobs


rpm -q zsh Check if RPM package zsh (z shell) is installed
'''dmesg | less''' –  


rpm -i zsh-4.3.9-4.fc11.i586.rpm Installs the zsh RPM package
'''dmesg | grep sdb''' –  


remove zsh: rpm -e zsh Uninstalls the zsh RPM package
'''tar -czf BackupFileneme.tar.gz /Folder''' Backup a the /Folder and all the files it contains into a single gzipped, tar file (BackupFilename)


yum Utility
'''tar -xvfz BackupFileneme.tar.gz''' – Extract the gzipped, tar file (BackupFilename) to some other location on a hard drive


yum install zsh Downloads and installs zsh package
'''find / -perm +6000 -type f > SUID-GUID-bits-Set.txt''' Search system for all SUID/GUID files


apt-get Utility


sudo apt-get install alien – Downloads and installs the program “alien”


sudo apt-get install chkconfig – Downloads and installs the program “chkconfig”


sudo apt-get remove package – Remove package
== Useful Configuration Files ==


apt-get autoremove – Removes additional programs associated with the main package installation
'''Shell Configuration files'''


    '''Per user configuration files'''
          ~/.bashrc
          ~/.profile


ldd /bin/ls – Display information about libraries used by the ls program
    '''Global configuration files'''
 
          /etc/bash.bashrc
 
          /etc/profile
6. Useful Management Commands
 
ps aux –
 
top –
 
kill pid – Send kill signal to process (pid)
 
jobs – List all currently running jobs
 
dmesg | less –
 
dmesg | grep sdb –
 
tar -czf BackupFileneme.tar.gz /Folder – Backup a the /Folder and all the files it contains into a single gzipped, tar file (BackupFilename)
 
tar -xvfz BackupFileneme.tar.gz – Extract the gzipped, tar file (BackupFilename) to some other location on a hard drive
 
find / -perm +6000 -type f > SUID-GUID-bits-Set.txt – Search system for all SUID/GUID files
 
 
 
7. Useful Configuration Files
 
Shell Configuration files
 
Per user configuration files
 
~/.bashrc
 
~/.profile
 
Global configuration files
 
/etc/bash.bashrc
 
/etc/profile

Latest revision as of 21:51, 15 December 2010

Getting Help

man <command> – Display command help

man find | grep <search string> – Locate specific help text within the manual

info – Provide man help in a different format


Directory navigation, basic shell tasks, and File Management

cd – Change working directory

cd .. – Change to parent directory

cd ~ – Change to home working directory

pwd – Display working directory

echo <line of text> – Display the line of text (useful for user friendly scripting)

echo $PATH – Display assignment to the environmental variable

time <command> - Time how long <command> took to execute

ls – Lists files in the current working directory

ls -a – Shows hidden files (hidden files start with a dot) as part of file listing

ls -l – Shows file detail

ls –F – Shows File type as part of file listing

history – Records commands typed at command prompt

    Ctrl+R to begin a backward search through history
    Ctrl+S to search forward through history
    Up Arrow and Down Arrow to move a line at a time through history

mkdir ch1 – Creates new directory ch1

mv file1 file2 – Moves file file1 to file2, renames file1 to file2

mv testfile changedfile

less – View file contents page-by-page

unset MYNAME – Removes the environment variable assignment assigned to MYNAME

exit – Terminate shell

cp -R one newone – Copies directory /one recursively to a new directory named /newone

rm etcbackup.tar.gz – Deletes file


Redirection and piping

ls > List-of-files.txt – Write list of files in current working directory to the file, List-of-files.txt

pwd >> List-of-files.txt – Append current working directory to the file “List-of-files.txt”

ps ax | grep string – Pipe output of ps ax to grep which searches for string.


Text processing commands

cat – Concatenate files together

cat /proc/interrupts – Display information from interrupts file (querying kernel about interrupts)

join – Merge file data from multiple files

sort – Sort file contents

nl – Generate line numbers for each line in a file

tail -20 /var/log/syslog – View last 20 entries posted to syslog file

less – File paging utility

grep string /var/log/* – Search for all occurrences of string in all log files in /var/log directory


Package Management

rpm Utility

    rpm -q zsh – Check if RPM package zsh (z shell) is installed
    rpm -i zsh-4.3.9-4.fc11.i586.rpm – Installs the zsh RPM package
    remove zsh: rpm -e zsh – Uninstalls the zsh RPM package

yum Utility

    yum install zsh – Downloads and installs zsh package

apt-get Utility

    sudo apt-get install alien – Downloads and installs the program “alien”
    sudo apt-get install chkconfig – Downloads and installs the program “chkconfig”
    sudo apt-get remove package – Remove package
    sudo apt-get install sysv-rc-conf - Provides gui view of all services running at each runlevel (works under server)
    apt-get autoremove – Removes additional programs associated with the main package installation


ldd /bin/ls – Display information about libraries used by the ls program


Useful Management Commands

ps aux

top

kill pid – Send kill signal to process (pid)

jobs – List all currently running jobs

dmesg | less

dmesg | grep sdb

tar -czf BackupFileneme.tar.gz /Folder – Backup a the /Folder and all the files it contains into a single gzipped, tar file (BackupFilename)

tar -xvfz BackupFileneme.tar.gz – Extract the gzipped, tar file (BackupFilename) to some other location on a hard drive

find / -perm +6000 -type f > SUID-GUID-bits-Set.txt – Search system for all SUID/GUID files



Useful Configuration Files

Shell Configuration files

    Per user configuration files
         ~/.bashrc
         ~/.profile
    Global configuration files
         /etc/bash.bashrc
         /etc/profile