Sponsored links


Go Back   Sat Industry Forums > Dreambox > Dreambox Chat
Register FAQ Members List Calendar Mark Forums Read

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 08-18-2004
xrayhead's Avatar
Registered User
 
Join Date: Aug 2004
Posts: 69
Thanks: 0
Thanked 1 Time in 1 Post
xrayhead is on a distinguished road
Your total guide to the DB Linux file system

Your total guide to the DB Linux file system


Hi All

This Unix/Linux help page is meant as a guide only and I cannot be held responsible for you killing your DreamBox. If the help file is read fully then you should gain some knowledge and understanding of the file system within your DB.

Moderators PLEASE move this if it is in the wrong section!!

I hope some of you can benefit from it, as I know a couple of years ago when I was building web sites I would have found this a Godsend.

If any of the moderators think that information is incorrect then please PM me and I will alter the text for you.

Sections covered are:

1. System Navigation
2. File Management
3. Directory Management
4. The powerful wildcards
5. The Linux cheat sheet
6. Understanding Linux file permissions and the chmod command
7. My easy chmod & file edit http://sat-industry.net/forums/showthread.php?t=12230

-------------------------------
1. System Navigation

Navigating around the files and directories of your hard drive could be a dreaded task for you, but it is necessary knowledge. If you were a user of command prompt interfaces such as MS-DOS, you'll have little trouble adjusting. You'll only need to learn a few new commands. If you're used to navigating using a graphical file manager, I don't know how it'll be like, but some concepts might require a little more clarification. Or maybe it'll be easier for you. Who knows? Everyone is different.

cd
As you might already have guessed, the cd command changes directories. It's a very common navigation command that you'll end up using, just like you might have done in MS-DOS.
You must put a space between cd and the ".." or else it won't work; Linux doesn't see the two dots as an extension to the cd command, but rather a different command altogether. It'll come to make sense if it doesn't already.

ls
The ls letters stand for list. It basically works the same way as the dir command in DOS. Only being a Unix command, you can do more with it. :-)
To view hidden files, use the -a flag with the ls command, i.e. ls -a.

To view more information about the files in a directory, use the -l flag with ls. It will show the file permissions as well as the file size, which are probably what are the most useful things to know about files.
You might occasionally want to have a listing of all the subdirectories, also. A simple -R flag will do, so you could look upon ls -R as a rough equivalent of the dir /s command in MS-DOS.

You can put flags together, so to view all the files in a directory, show their permissions/size, and view all the files that way through the subdirectories, you could type ls -laR.

pwd
This command simply shows what directory you're in at the moment. It stands for "Print Working Directory". It's useful for scripting in case you might ever want to refer to your current directory.

-------------------------------------------
2. File Management


A lot of people, surprisingly for me, prefer to use graphical file managers. Fortunately for me, I wasn't spoiled like that and used commands in DOS. That made it a bit easier for me to make the transition to Linux. Most of the file management Linux gurus do is through the command line, so if you learn to use the commands, you can brag that you're a guru. Well, almost.

cp
Copying works very much the same. The cp command can be used just like the MS-DOS copy command, only remember that directories are separated with slashes (/) instead of backslashes (\). So a basic command line is just cp filename1 filename2.

You can move an entire directory to its new destination. Let's say you want to copy a directory (and all of its contents) from where you are to be /home/jack/newdirectory/. You would type cp -rpf olddirectory /home/jack/newdirectory.
To issue this command you would have to be in the directory where the subdirectory "olddirectory" is actually located.

mv
The mv command can be used both to move files and to rename them. The syntax is mv fileone filetwo, where "fileone" is the original file name and "filetwo" will be the new file name.

rm
The rm command is used for removing files. You use it just like the del or delete command in MS-DOS. Let's say you want to remove a file called foobar in your current directory. To do that, simply type rm foobar. Note that there is no "Recycle Bin" like in Windows. So when you delete a file, it's gone for good dudes!!

------------------------------------
3. Directory Management

To delete something in some other directory, use the full path as the file name. For example, if you want to delete a file called "oldkeys" that's in the directory /usr/local/src/, you would type rm /usr/local/src/oldkeys.

To remove an entire directory and its contents, type rm -rf /directory where "/directory" is the path to the directory that you want to delete. If you're wondering, the "rf" stands for "recursive" and "force". Be very careful with this command, as it can wreak havoc easily if misused.

Editing
If you haven't figured out how important a text editor is, you soon will. Graphical interfaces can't shield you forever, and those utilities have their limits. However, as I can’t be assed to mess around with VI. I just use Flash FXP to edit my files (most free FTP programs work fine as well).

There are two ways to do this.
1. You can FTP into your Dream Box and right click the file you want to edit. This is good if you just have a quick mod to perform. If however you want to edit a file with a whole lot of text then go to the next step.
2. FTP to your Dream Box and download the file you want to edit to your PC. Now right click the file and chose open with Notepad or WordPad, edit the file and FTP it back to your box (over righting the file you just downloaded).
Job done!!

< Creating directories >
Creating a new, empty directory is very easy. You use the mkdir command:
$ mkdir dreamboxkeys_test
That's it. It's really that easy!


-----------------------------------------
4. The powerful wildcards


< The powerful wildcards >
Without these cool little things called shell wildcards, working on the Linux command line is pretty painful. So make sure you put the wildcards into good use!


< What are wildcards >
Wildcards are a feature that makes the command line much more powerful than any GUI file managers. You see, if you want to select a big group of files in a graphical file manager, you usually have to select them with your mouse. This may seem simple, but in some cases it can be very frustrating. For example, suppose you have a directory with a huge amount of all kinds of files and subdirectories, and you decide to move all the HTML files, that have the word "linux" somewhere in the middle of their names, from that big directory into another directory. What's a simple way to do this? If the directory contains a huge amount of differently named HTML files, your task is everything but simple!

In Linux that task is just as simple to perform as moving only one HTML file, and it's so easy because of the shell wildcards. Wildcards are special characters that allow you to select filenames that match certain patterns of characters. This helps you to select even a big group of files with typing just a few characters, and in most cases it's easier than selecting the files with a mouse.


< Wildcard examples >
Let's have a few examples. Probably the * character is already familiar to you, because it's widely used in many other places, too, not just in Linux. For example, the following removes every file from the current directory:
$ rm *

The following command moves all the HTML files, that have the word "linux" in their names, from the working directory into a directory named dir1:
$ mv *linux*.html dir1


The following displays all files that begin with d and end with .txt:
$ less d*.txt

The following command removes all files whose names begin with junk., followed by exactly three characters:
$ rm junk.???



-----------------------------------------
5. The Linux cheat sheet


A small Linux cheat sheet, introducing the very basic and essential commands.
Moving around in the file system
Command Action
pwd show what dir you're in.
ls List the contents of a dir.
ls -l List the contents of a dir and show additional info of the files.
ls -a List all files, including hidden files.
cd Change directory.
cd .. Go to the parent directory.

Manipulating files and directories
Command Action
cp Copy a file.
cp -i Copy a file and ask before overwriting.
cp -r Copy a directory with its contents.
mv Move or rename a file.
mv -i Move or rename a file and ask before overwriting.
rm Remove a file.
rm -r Remove a directory with its contents.
rm -i Ask before removing a file. Good to use with the -r option.
mkdir Make a directory.
rmdir Remove an empty directory.
Reply With Quote
Sponsored links
  #2 (permalink)  
Old 08-18-2004
xrayhead's Avatar
Registered User
 
Join Date: Aug 2004
Posts: 69
Thanks: 0
Thanked 1 Time in 1 Post
xrayhead is on a distinguished road
Part Two

------------------------------------------------------------------
6. Understanding Linux file permissions and the chmod command

Now I know that this has been covered over and over again on this board but please read on. I have tried to explain this as well as I can and also show an easy way to edit files and their permissions.


In a secure multi-user environment like Linux, file permissions access
rights are defined. However, these access rights can cause problems for
new users who are used to the access-anything style of Windows!!!

Linux is a proper multi-user environment. In a multi-user environment,
security of user and system data is very important. Access should be given
only to users who need to access the data. Since Linux is essentially a
server OS, good and efficient file security is built right into Linux. Of
course, such security does create problems for users, especially novice
users. Many user queries are due to incorrect file permissions or just
because a user ignores that fact that the file permissions do not allow
access.

First, let's check out the file permissions. File permissions are defined
for users, groups and others. User would be the username that you are
logging in as. Further more, users can be organized into groups for better
administration and control. Each user will belong to at least one default
group. Others includes anyone the above categories exclude.

Given below is the result of an 'ls -l'

drwxr-x--- 2 mayank freeos 4096 Dec 28 04:09 tmp
-rw-r--r-- 1 mayank freeos 969 Dec 21 02:32 foo
-rwxr-xr-x 1 mayank freeos 345 Sep 1 04:12 somefile

The file permissions.
The permission bits r,w and x are assigned a number.

r = 4
w = 2
x = 1

Now you can use numbers, which are the sum of the various permission bits.
E.g - rwx will be 4+3+1 = 7. rx becomes 4+1 = 5. The chmod command now
becomes

chmod xyz somefilename

where x,y and z are numbers representing the permissions of user, group
and others respectively. Each number is the sum of the permissions to be
set and are calculated as given above.

Chmod 644 somefilename

6 = 4 + 2 = rw
4 = r
4 = r

As you can see above, the permissions for somefilename are being set to -rwr--r--.
Refer to the table below as a quick reference.

0 - ---
1 - --x
2 - -w-
3 - -wx
4 - r--
5 - r-x
6 - rw-
7 - rwx

In addition to the file permission, you can also modify the owner and
group of the file but I dont think we need to go into that.

Now all this is ok but I here you saying “I just want an easy way to change the file permissions”. Well the above could not be more simpler BUT if you want a graphical way of changing the file permissions then you may want to have a look at this thread I posted “The easy way to chmod files”
http://sat-industry.net/forums/showthread.php?t=12230

Well I hope this has helped someone out as I remember when I first started working with UNIX files I could have done with reading this.

Regards

Xrayhead

Last edited by xrayhead : 08-18-2004 at 03:55 AM.
Reply With Quote
  #3 (permalink)  
Old 08-21-2004
Registered User
 
Join Date: Aug 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
guzpot1 is on a distinguished road
Thumbs up Chmod

Flashfxp is a handy ftp util to use as well
nice one for the thread xray
Reply With Quote
  #4 (permalink)  
Old 08-22-2004
xrayhead's Avatar
Registered User
 
Join Date: Aug 2004
Posts: 69
Thanks: 0
Thanked 1 Time in 1 Post
xrayhead is on a distinguished road
Quote:
Originally Posted by guzpot1
Flashfxp is a handy ftp util to use as well
nice one for the thread xray
If you want to download Flash you can do so here
Reply With Quote
  #5 (permalink)  
Old 08-22-2004
Registered User
 
Join Date: Oct 2003
Posts: 488
Thanks: 0
Thanked 0 Times in 0 Posts
robb is on a distinguished road
Also you don't need to remember those magic numbers, only the 'r' 'w' and 'x' names for 'read', 'write' or 'execute'

For example, to add the 'x' permission to all three colums of the premissions you can use 'a+x' which means 'all + execute'.

Example:
root@dreambox /tmp > ls -al file
-rw-r--r-- 1 root root 0 Aug 22 08:35 file
root@dreambox /tmp > chmod a+x file
root@dreambox /tmp > ls -al file
-rwxr-xr-x 1 root root 0 Aug 22 08:35 file

(instead of 'a' it is also possible to use 'u', 'g' or 'o' for 'user', 'group' and 'other' but it is rarely needed on the dreambox where everything runs as user root anyway)
Reply With Quote
  #6 (permalink)  
Old 09-29-2004
Registered User
 
Join Date: Dec 2003
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Mariner is on a distinguished road
Thank you

Great for linux newcomers
Reply With Quote
  #7 (permalink)  
Old 10-02-2004
xrayhead's Avatar
Registered User
 
Join Date: Aug 2004
Posts: 69
Thanks: 0
Thanked 1 Time in 1 Post
xrayhead is on a distinguished road
Glad I could help, and thanks for taking the time to reply.

Xrayhead
Reply With Quote
  #8 (permalink)  
Old 10-03-2004
ded ded is offline
Registered User
 
Join Date: Jan 2004
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
ded is on a distinguished road
Well Done. I'm only six months into linux but already I can see it's far superior and more powerful then W££££WS. I recommend to all.
Don't fear the penguins give it a try.
The cost of Linux o/s is FREE with thousands of FREE applications.
Reply With Quote
  #9 (permalink)  
Old 10-03-2004
Alpha_ssfteam's Avatar
Registered User
 
Join Date: Dec 2003
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Alpha_ssfteam is on a distinguished road
Nice work xrayhead

Rgd Alpha
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Multiboot for 7020 - public beta noggie Dreambox Development 265 08-22-2005 08:29 AM
Using 7020 dev. kit for 7000 - progress report noggie Dreambox Development 48 02-07-2005 10:46 PM
File System Check & Auto Repair cascade2 Tips, Tricks & Hints 5 11-27-2004 08:00 AM
File System Check Mariner Tips, Tricks & Hints 6 11-20-2004 06:44 AM
I can't delete a directory Alfred83 The_Hydra Images 9 11-11-2004 11:57 PM


All times are GMT +10. The time now is 11:12 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Page generated in 0.41610 seconds with 10 queries