Beginners – Working With Files and Directories

Valic —  January 14, 2013 — Leave a comment

The following commands can be used to:

  • find out information about files
  • display files
  • copy, move or delete files
Linux Command Command Description
file This command shows you out what kind of file it is.

Example:  file /bin/ls will tells you that it is a Linux executable file.

cat Display the contents of a text file on the screen. Example: cat filelist.txt will display the contect of the file filelist.txt
head Display the first 10 lines of a text file. Example: head /var/log/messages This will display the first 10 lines from the messages log file.
tail Display the last 10 lines of a text file. Example:  tail /var/log/messagesThis will display the last 10 lines from the messages log file.
tail -f Display the last 10 lines of a text file and then output appended data as the file grows.

Example: tail -f /var/log/messages

cp Copies a file from one location to another. Example: cp file.txt /tmp
Thos commadn copies the file.txt file to the /tmp directory
mv Moves a file to a new location, or renames it. For example: mv file.txt /tmp
rm Delete a file. Example: rm /tmp/file.txt
mkdir Make Directory. Example: mkdir /tmp/mydirectory
rmdir Remove Directory. Example: rmdir /tmp/mydirectory
NOTE: You can practice these commands by yourself and find more about all commands using the man command.

Valic

Posts Twitter Facebook

Editor in Chief at Debian-Tutorials, Linux enthusiast.

No Comments

Be the first to start the conversation.

Leave a Reply