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.