Wednesday, June 6, 2012

Some useful commands in Debian 5/6

head and tail shows the first 10 and the last 10 lines of a file respectively

head -n 1 will show the first line and tail -n 1 will show the last line

STDERR 2>error.txt

ls -l sourav 2>> error.txt

will put the error in the file error txt

we can watch the ongoing errors in a different terminal using the command 

watch tail error.txt

file filename returns the type of the file

for example file * shows every file's type that is presented in the directory

wc -l filename shows the number of lines in a file

wc is for word count

seq 50 will show the sequence from 1 to 50

creating a loop in the terminal to print hello couple of times.

for i in `seq 50`;do echo "Hello"; done

or may be like this

for i in `seq 50`;do echo "Hello - $i"; done

suppose we want to see the number of files in a directory using a loop

for i in `ls -a`;do echo "File - $i"; done | wc -l

or may be see the files one by one using a loop

for i in `ls -a`;do echo "File - $i"; done 

reset to create a new buffer(any command will now run on a new buffer after the command reset)

free to see the info about memory

free -m returns the output in a more readable format

kill a process using top

type top

type k

enter the pid of the process

No comments:

Post a Comment