To find the type of a file
file <file name>
To create a file
cat > filename.txt
//type the contents and press Ctrl+D to exit
To display the contents of a text file
cat <file name>
To view the contents of a file page by page
more <file name>
//traversal only in forward direction
less <file name>
//traversal in both directions
To display first few lines of a file
head <file name>
head -5 <file name>
//first 5 lines
To display last few lines of a file
tail <file name>
tail -5 <file name>
//last 5 lines
To display the last few lines of a text file, and then output
appended data as the file grows (very useful for following log
files!)
tail -f /var/log/messages
To copy a file from one location to another
cp [-r] <source file/directory> <destination>
eg: cp mp3files.txt /tmp
To move a file to a new location
mv <source> <destination>
eg: mv mp3files.txt /tmp
To delete a file
rm [-r] <filename/directory name>
eg: rm /tmp/mp3files.txt
0 Comments