file search1. print top lines head sample.log head -n 20 /path/to/logfile.log
2. print bottom lines tail sample.log terminal commandscontrol A - begining of the linecontrol E - end of the linecontrol right arrowcontrol left arrowcontrol U start line deletecontrol K start from custor delete
file system
cd when folder name has spacecd Exercise Files errorcd Exercise\ Files
ls -R inside directoryls --color=always
rm -sample?.txt
vs
cat sample.txt | cat -n | tail -n4
grep "hello" sample.txt - simple searchgrep -in "hello" sample.txt - with line numbers /ignore case with line numbresgrep -vi "hello" sample.txt - with line numbers /ignore matching case and print remaininggrep -n "hello" sample.txt - with line numbersgrep -E "[hijk]" sample.txt - search for letters and shows the resultsgrep -E "/w{6,}" sample.txt - count words and shows the results
log analysis with awk commandawk '/error/ {print}' /var/log/syslogawk '{print $2}' sample.txtawk '{print $2 "\t" $1}' sample.txt | sort -n more filter on tablular data
sed s/Orange/Red/ sample_data to edit& replace texts for substituteg for global replace
sort sample.txtsort -k2 -n sample.txt sort the datasort -u sample.txt - remove dublicates only unique printrev tac tr
tar -xvf log.tar.gz
log analysisless filenamecat filename | grep "string" | awk '{print $9}' |sort -u > users.txt
free -hcat /proc/cpuinfo - c
df -h memory information
file search
1. print top lines
head sample.log
head -n 20 /path/to/logfile.log
2. print bottom lines
tail sample.log
terminal commands
control A - begining of the line
control E - end of the line
control right arrow
control left arrow
control U start line delete
control K start from custor delete
file system
cd
when folder name has space
cd Exercise Files error
cd Exercise\ Files
ls -R inside directory
ls --color=always
rm -sample?.txt
vs
cat sample.txt | cat -n | tail -n4
grep "hello" sample.txt - simple search
grep -in "hello" sample.txt - with line numbers /ignore case with line numbres
grep -vi "hello" sample.txt - with line numbers /ignore matching case and print remaining
grep -n "hello" sample.txt - with line numbers
grep -E "[hijk]" sample.txt - search for letters and shows the results
grep -E "/w{6,}" sample.txt - count words and shows the results
log analysis with awk command
awk '/error/ {print}' /var/log/syslog
awk '{print $2}' sample.txt
awk '{print $2 "\t" $1}' sample.txt | sort -n more filter on tablular data
sed s/Orange/Red/ sample_data to edit& replace text
s for substitute
g for global replace
sort sample.txt
sort -k2 -n sample.txt sort the data
sort -u sample.txt - remove dublicates only unique print
rev tac tr
tar -xvf log.tar.gz
log analysis
less filename
cat filename | grep "string" | awk '{print $9}' |sort -u > users.txt
free -h
cat /proc/cpuinfo - c
df -h memory information
copy the text from ssh editor to local
cntrl+insert for copy
shift +insert for paste
grep commands for daily use
grep -B 3 -A 2 'Invalid user' /var/log/auth.log
https://www.loggly.com/ultimate-guide/troubleshooting-with-linux-logs/
refer the link https://phoenixnap.com/kb/grep-command-linux-unix-examples
scp command to transfer files
for more refer this link https://www.youtube.com/watch?v=fmMg6cyww14
1. search text in vi editor
- Press ESC key.
- Type /vivek.
- Hit n to search forwards for the next occurrence of word named “vivek”. You can press N to search backwards.
- Press ESC key.
- Type /vivek.
- Hit n to search forwards for the next occurrence of word named “vivek”. You can press N to search backwards.
Find Files linux commad
find / -name "*conf"
find /home/exampleuser/ -name "*conf"
find / -name "*conf"
find /home/exampleuser/ -name "*conf"
2. How to unpack (ungzip, unarchive) a tar.gz file
For many systems, REBOL is distributed as a tar gz file. This is a common archive format. Here's how to unpack it...
For tar.gz
To unpack a tar.gz file, you can use the tar command from the shell. Here's an example:
tar -xzf rebol.tar.gz
The result will be a new directory containing the files.
(Also, on many systems, when you download the tar.gz from a web browser, an unpacker will open, and you can just use that.)
For just .gz (.gzip)
In some cases the file is just a gzip format, not tar. Then you can use:
gunzip rebol.gz
In order to execute it, you will need to add execute permissions to the file:
chmod +x rebol
for more refer below videos on detailed commands