Edit History Actions Discussion

Diff for "Howto/FileManagement"

Differences between revisions 2 and 3
Revision 2 as of 2007-11-05 18:52:50
Size: 5428
Comment:
Revision 3 as of 2007-11-06 06:40:58
Size: 9029
Editor: tommsmith
Comment: Content Added(bushblows)
Deletions are marked like this. Additions are marked like this.
Line 10: Line 10:
Line 89: Line 88:

Detailed Layout.
{{{-rw-r--r-- 1 independence shelluser 0 2007-11-05 19:32 myfile.txt
|\ /\ /\ / | | | | | | |
| | | | | | | | | | |-File name
| | | | | | | | | |-Time created/modified
| | | | | | | | |-Date created/modified
| | | | | | | |-Size of file
| | | | | | |-Group the file is in
| | | | | |-Owner's username
| | | | |-Number of directories
| | | |-Other permissions
| | |-Group permissions
| |-Owner permissions
|-File type}}}
Line 149: Line 163:
==== Changing Permissions(Cont...) ====

We can also change permission of user, group, others with one command. We will get into this now. We will be changing permissions of files with numbers.

So lets first explain how to understand what numbers control what permission, it is rather simple actually, their are only 3 numbers you need to remember.

 * read == 4
 * write == 2
 * execute == 1

Basicly we are just doing fundamental adding, to get the number you first decide what permissions you want to set, then add those numbers together, we need to do this for all 3 categories, user, group, and other. So if we want a permission of read/write but no execute then the number would be 6, and if we wanted read/execute only the number would be 5.

well now that we understand the basic idea, lets do some examples.

The following example will make myfile.txt user read/write/execute, group read/execute, and other read.

{{{chmod 754 myfile.txt
ls -l
-rwxr-xr-- 1 bushblows shelluser 0 2007-11-05 19:32 myfile.txt}}}

Now we will make myfile.txt user read/write/execute, group read/write, other read/write.

{{{chmod 766 myfile.txt
-rwxrw-rw- 1 bushblows shelluser 0 2007-11-05 19:32 myfile.txt}}}
Line 157: Line 196:
== Compressing/achives ==

tar

gzip

bzip
== Compressing/Archives ==

Archives and compression are very handy in many different situations, and this is the topic we will talk about in this section. The most generally used archive/compression software in *nix is tar(archive), gzip(compression), and bzip(compression).

Tar is software used for archiving files/directories, but also supports flags to compress as well, we will touch on both a simple archive and an archive with compression.

To just archive a directory with files/directories in it, we would use this command.

{{{tar cf my_archive.tar /destination/of/directory
}}}

And our archived file would be my_archive.tar in our current working directory.


So we archived a file, but now we need a file from the archive, we need to un-archive it, we would do so with this command.

{{{tar xf my_archive.tar
}}}

Now to archive and compress a file, we will archive with tar and use gzip's compression so we need to name our file *.tar.gz commonly known as a tarball.
{{{tar cfz my_archive_compressed.tar.gz /destination/to/directory
}}}

So we archived and compressed our file but need a file from inside, so lets un-compress it and un-archive it.
We would do so with this command.
{{{tar xfz my_archive_compressed.tar.gz
}}}

More flags and usage for tar can be found with the command 'man tar'.


So lets just compress a file with no archiving, we will start with gzip.
This command will compress the desired file.
{{{gzip somefile.txt
}}}

Now if this file is a directory, then we need an extra flag unlike tar, so we would do so with this command.
{{{gzip -r some_directory
}}}

Uncompressing is pretty simple, however we use a different command to uncompress, with this command we would uncompress our file.
{{{gunzip some_file.gz
}}}

File Management

This is work in progress, not complete. Please help and add more stuff!

This is a howto explaining how to manage files on a UNIX system. This is very important to get the most out of your shell account.

Basics

The very basics of file management is how to list, create, copy, move and delete files and directories. To create a file, you can open up a text editor, write some text, and then save it. To do this with nano, type:

{{{nano myfile.txt }}}

This will open up the text editor nano. Write some text and press ctrl-x to exit, nano will then ask if you want to save the file. You can also use ctrl-o to just save the file, without exiting nano.

You can also use this command to just create a new empty file:

{{{touch newfile }}}

To create a new directory, use this command:

{{{mkdir mydir }}}

To see your newly created files and directories, use the command ls: