next up previous contents index
Next: Editing a File Up: Basic Bash Commands Previous: Moving Around the System   Contents   Index

File Manipulation

There are many ways to alter files on your system. You can copy, delete, move, change attributes etc. Here is the three basic file manipulation commands, cp, rm, and mv -> Copy, remove and move. They are used as follows:

$ cp file1 file2

ex: $ cp /home/nick/new_httpd.conf /etc/httpd/conf/httpd.conf

$ rm file

ex: $ rm /home/nick/new_httpd.conf

$ mv file1 file2

ex: $ mv /home/nick/new_httpd.conf /etc/httpd/conf/httpd.conf

You also have control over the attributes and ownership of a file. Running chown and chgrp you can change the files ownerships:

$ chown nick *.html

$ chgrp nick *.html

The above two commands will give user nick complete ownership over every html file in the current directory. You can shorten the above command by typing:

$ chown nick:nick *.html
This changes both the ownership and group in one shot. You can change the file permissions using the chmod program. By typing:

$ chmod 644 *.html
That will change the access to read/write by the owner and read only by users in the specified group and all users. There are many more options, too many to list here, chmod can use.


next up previous contents index
Next: Editing a File Up: Basic Bash Commands Previous: Moving Around the System   Contents   Index