Show Menu

LFCS_Module1_EssentialCommand Cheat Sheet by

linux

MAN page

man -a useradd
useradd command in all sections
man -k passwd | grep 8
searching passwd keyword in man page from section 8
man 8 useradd
showing useradd command from section 8
man man
showing man command help

Hard links, soft links, finding files

ln /etc/hosts myhosts
create hard links myhosts to /etc/hosts
ln -s /etc/h­osts/ myhosts
create symbolic links myhosts
find /etc -name hosts
Find in /etc files with exact name "­hos­ts"
find /etc -name "­ho­sts­"
Find in /etc files with "­hos­ts" in its name
find /etc -name "­ho­sts­" -exec cp {} /etc/test/ \;
Find in /etc file with "­hos­ts" in name and copy it to /etc/test
find /etc -size +100K 2>/­dev­/null
File in /etc files over 100Kb and send error to /dev/null
grep student /etc/* 2>/­dev­/null
Find in /etc files with "­stu­den­t" in content
grep -l student /etc/* 2>/­dev­/null
List only the direct­ories
find /etc -exec grep -l student {} \; 2>/­dev­/null; cp {} /find/­con­tents/ \; 2>/­dev­/null
Find all direct­ories and sub with files containing student in content and copy the result to /find/­content

Admini­str­ative Tasks

visudo
Edit sudo config­uration file
chvt t
Change virtual terminal 5
/etc/s­ecu­retty
Secure console file, delete 1 will no longer have access to that console
 

Input Output Redire­ction

>
overwrite
<
send into command
>>
append
<<
append into command or file
2> /dev/null
redirect error to null file

Text Processing Utilities

cut -d : -f 3 /etc/p­asswd
Display third column using "­:" delimiter in /etc/p­asswd
cut -d : -f 1 /etc/p­asswd | sort | tr [:lowe­rcase:] [:uppe­rcase:]
Display all username in /etc/p­asswd and translate all lowercase to uppercase
awk -F : ' { print $1 } ' /etc/p­asswd
Display first column using "­:" field delimiter (-F)
sed -i -e '10d' grepfile1
Delete (10d) intera­ctively (-i) using edit option(-e) the tenth line

Archive, Backup, Compress, Uncompress

tar cvf name.tar /dir
Create name.tar file from /dir
tar -xvfz archiv­e.t­ar.gzip -C /targe­t/dir
Extract archiv­e.t­ar.gzip to /tar/dir
 

Create, Delete, Copy, Move

ls -al /etc
list all files (-a) with all info (-l) in /etc
ls -r
list sub-di­rec­tories (-r)
cp -R /etc/hosts ~/files/
copy all (-R) in hosts to home/f­iles/
mkdir -p /etc/p­hotos
make directory etc and sub-di­rectory photos
mv /tmp/test ~
move test to home directory
rm -rf
remove recurs­ively and ignore non existent file

head, tail,

head -n 5 /etc/p­asswd
Display first 5 lines in /etc/p­asswd
tail -f /var­/lo­g/m­ess­ages
Display the recent system messages

Regular expres­sions

note
Use with sed, vim, awk, grep
^
Start of a string
^abc
abc, abcdef­,abc123
$
End of a string
abc$
abc,12­3ab­c,f­deabc
|
Alteration
1|8
1,8
{...}
Exact quanity
ab{2}c
abbc
[...]
Explicit set of character to match
a[bB]c
abc,aBc
*
Null or more of the preceding character
ab*c
ac,abc­,abbbbc
(...)
Group of character
(123){3}
123123123
+
One or more of predceding character
ab+c
abc,abbbbc
?
Null or 1 of the preceding character
ab?c
abc, ac
.
Any single character
\s
Whites­paces
.*
Zero or more of any character

Download the LFCS_Module1_EssentialCommand Cheat Sheet

1 Page
//media.cheatography.com/storage/thumb/nhatlong0605_lfcs-module1-essentialcommand.750.jpg

PDF (recommended)

Alternative Downloads

Share This Cheat Sheet!

 

Comments

No comments yet. Add yours below!

Add a Comment

Your Comment

Please enter your name.

    Please enter your email address

      Please enter your Comment.

          Related Cheat Sheets

          Linux Command Line Cheat Sheet
          mod_rewrite Cheat Sheet
          Vim NERDTree Cheat Sheet

          More Cheat Sheets by nhatlong0605