Basic linux commands II

Written by kisa

On May 17, 2020

grep

 

(global regular expression print)

$grep “failed*” -i log_file

print all lines with the word “failed” + * (-i  ignore case) in log_file file.

head

prints first 10 lines of a file.

$head -n 20 file_name

prints 20 lines of a file_name.

$head -17 file_name2

prints 17 lines of a file_name2.

tail

Same as head but prints the tail of a file.

ALSO

With the key -f keeps looking at the changes to the file

$sudo tail -f /var/log/faillog 

(kali)

$sudo tail -f /var/log/secure

(centOs)

prints in-real-time changes of a file. In this example it’s the authentication file.

more & less

viewing and navigation

$more file_name

shows the file and navigation with pageDown pageUp or line by line.

$less file_name

navigation & search (with ‘/searchWord’) in a file.


 

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *