Linux command guide: Difference between revisions
WarnerGouin (talk | contribs) (Created page with 'Contents 1. Getting Help 2. Directory Navigation, basic shell tasks, and File Management 3. Redirection and Piping 4. Text Processing 5. Package Management 6. Useful Management C…') |
WarnerGouin (talk | contribs) No edit summary |
||
Line 1: | Line 1: | ||
Contents | Contents | ||
1. Getting Help | 1. Getting Help | ||
2. Directory Navigation, basic shell tasks, and File Management | 2. Directory Navigation, basic shell tasks, and File Management | ||
3. Redirection and Piping | 3. Redirection and Piping | ||
4. Text Processing | 4. Text Processing | ||
5. Package Management | 5. Package Management | ||
6. Useful Management Commands | 6. Useful Management Commands | ||
7. Useful Configuration Files | 7. Useful Configuration Files | ||
1. Getting Help | 1. Getting Help | ||
man <command> – Display command help | man <command> – Display command help | ||
man find | grep <search string> – Locate specific help text within the manual | man find | grep <search string> – Locate specific help text within the manual | ||
info – Provide man help in a different format | info – Provide man help in a different format | ||
2. Directory navigation, basic shell tasks, and File Management | 2. Directory navigation, basic shell tasks, and File Management | ||
cd – Change working directory | cd – Change working directory | ||
cd .. – Change to parent directory | cd .. – Change to parent directory | ||
cd ~ – Change to home working directory | cd ~ – Change to home working directory | ||
pwd – Display working directory | pwd – Display working directory | ||
echo <line of text> – Display the line of text (useful for user friendly scripting) | echo <line of text> – Display the line of text (useful for user friendly scripting) | ||
echo $PATH – Display assignment to the environmental variable | echo $PATH – Display assignment to the environmental variable | ||
time <command> - Time how long <command> took to execute | time <command> - Time how long <command> took to execute | ||
ls – Lists files in the current working directory | 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 -a – Shows hidden files (hidden files start with a dot) as part of file listing | ||
ls -l – Shows file detail | ls -l – Shows file detail | ||
ls –F – Shows File type as part of file listing | ls –F – Shows File type as part of file listing | ||
history – Records commands typed at command prompt | history – Records commands typed at command prompt | ||
Ctrl+R to begin a backward search through history | Ctrl+R to begin a backward search through history | ||
Ctrl+S to search forward through history | Ctrl+S to search forward through history | ||
Up Arrow and Down Arrow to move a line at a time through history | Up Arrow and Down Arrow to move a line at a time through history | ||
mkdir ch1 – Creates new directory ch1 | mkdir ch1 – Creates new directory ch1 | ||
mv file1 file2 – Moves file file1 to file2, renames file1 to file2 | mv file1 file2 – Moves file file1 to file2, renames file1 to file2 | ||
mv testfile changedfile | mv testfile changedfile | ||
less – View file contents page-by-page | less – View file contents page-by-page | ||
unset MYNAME – Removes the environment variable assignment assigned to MYNAME | unset MYNAME – Removes the environment variable assignment assigned to MYNAME | ||
exit – Terminate shell | exit – Terminate shell | ||
cp -R one newone – Copies directory /one recursively to a new directory named /newone | cp -R one newone – Copies directory /one recursively to a new directory named /newone | ||
rm etcbackup.tar.gz – Deletes file | rm etcbackup.tar.gz – Deletes file | ||
3. Redirection and piping | 3. Redirection and piping | ||
ls > List-of-files.txt – Write list of files in current working directory to the file, List-of-files.txt | 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” | 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. | ps ax | grep string – Pipe output of ps ax to grep which searches for string. | ||
4. Text processing commands | 4. Text processing commands | ||
cat – Concatenate files together | cat – Concatenate files together | ||
cat /proc/interrupts – Display information from interrupts file (querying kernel about interrupts) | cat /proc/interrupts – Display information from interrupts file (querying kernel about interrupts) | ||
join – Merge file data from multiple files | join – Merge file data from multiple files | ||
sort – Sort file contents | sort – Sort file contents | ||
nl – Generate line numbers for each line in a file | nl – Generate line numbers for each line in a file | ||
tail -20 /var/log/syslog – View last 20 entries posted to syslog file | tail -20 /var/log/syslog – View last 20 entries posted to syslog file | ||
less – File paging utility | less – File paging utility | ||
grep string /var/log/* – Search for all occurrences of string in all log files in /var/log directory | grep string /var/log/* – Search for all occurrences of string in all log files in /var/log directory | ||
5. 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 | remove zsh: rpm -e zsh – Uninstalls the zsh RPM package | ||
yum Utility | yum Utility | ||
yum install zsh – Downloads and installs zsh package | yum install zsh – Downloads and installs zsh package | ||
apt-get Utility | apt-get Utility | ||
sudo apt-get install alien – Downloads and installs the program “alien” | 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 install chkconfig – Downloads and installs the program “chkconfig” | ||
sudo apt-get remove package – Remove package | sudo apt-get remove package – Remove package | ||
apt-get autoremove – Removes additional programs associated with the main package installation | apt-get autoremove – Removes additional programs associated with the main package installation | ||
ldd /bin/ls – Display information about libraries used by the ls program | ldd /bin/ls – Display information about libraries used by the ls program | ||
6. Useful Management Commands | 6. Useful Management Commands | ||
ps aux – | ps aux – | ||
top – | top – | ||
kill pid – Send kill signal to process (pid) | kill pid – Send kill signal to process (pid) | ||
jobs – List all currently running jobs | jobs – List all currently running jobs | ||
dmesg | less – | dmesg | less – | ||
dmesg | grep sdb – | 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 -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 | 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 | find / -perm +6000 -type f > SUID-GUID-bits-Set.txt – Search system for all SUID/GUID files | ||
7. Useful Configuration Files | 7. Useful Configuration Files | ||
Shell Configuration files | Shell Configuration files | ||
Per user configuration files | Per user configuration files | ||
~/.bashrc | ~/.bashrc | ||
~/.profile | ~/.profile | ||
Global configuration files | Global configuration files | ||
/etc/bash.bashrc | /etc/bash.bashrc | ||
/etc/profile | /etc/profile |
Revision as of 21:29, 15 December 2010
Contents
1. Getting Help
2. Directory Navigation, basic shell tasks, and File Management
3. Redirection and Piping
4. Text Processing
5. Package Management
6. Useful Management Commands
7. Useful Configuration Files
1. 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
2. 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
3. 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.
4. 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
5. 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
apt-get autoremove – Removes additional programs associated with the main package installation
ldd /bin/ls – Display information about libraries used by the ls program
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