From b76270bf9e6dd375e495fec92140a79a79415d27 Mon Sep 17 00:00:00 2001 From: Patrick J Volkerding Date: Wed, 19 May 2010 08:58:23 +0000 Subject: Slackware 13.1 Wed May 19 08:58:23 UTC 2010 Slackware 13.1 x86_64 stable is released! Lots of thanks are due -- see the RELEASE_NOTES and the rest of the ChangeLog for credits. The ISOs are on their way to replication, a 6 CD-ROM 32-bit set and a dual-sided 32-bit/64-bit x86/x86_64 DVD. We are taking pre-orders now at store.slackware.com, and offering a discount if you sign up for a subscription. Consider picking up a copy to help support the project. Thanks again to the Slackware community for testing, contributing, and generally holding us to a high level of quality. :-) Enjoy! --- misc/slackbook/html/file-commands.html | 275 +++++++++++++++++++++++++++++++++ 1 file changed, 275 insertions(+) create mode 100644 misc/slackbook/html/file-commands.html (limited to 'misc/slackbook/html/file-commands.html') diff --git a/misc/slackbook/html/file-commands.html b/misc/slackbook/html/file-commands.html new file mode 100644 index 00000000..b541735d --- /dev/null +++ b/misc/slackbook/html/file-commands.html @@ -0,0 +1,275 @@ + + + + +Handling Files and Directories + + + + + + + + + + +
+

Chapter 10 Handling Files and +Directories

+ + + +

Linux aims to the most Unix-like it can be. Traditionally, Unix operating systems have +been command-line oriented. We do have a graphical user interface in Slackware, but the +command-line is still the main level of control for the system. Therefore, it is +important to understand some of the basic file management commands.

+ +

The following sections explain the common file management commands and provide +examples of how they are used. There are many other commands, but these will help you get +started. Also, the commands are only briefly discussed here. You will find more detail in +the accompanying man pages for each command.

+ +
+

10.1 +Navigation : ls, cd, and pwd

+ +
+

10.1.1 ls

+ +

This command lists files in a directory. Windows and DOS users will notice its +similarity to the dir command. By itself, ls(1) will list the files in the current directory. To see what's in +your root directory, you could issue these commands:

+ + + + + +
+
+% cd /
+% ls
+bin   cdr    dev  home  lost+found  proc  sbin   tmp  var
+boot  cdrom  etc  lib   mnt         root  suncd  usr  vmlinuz
+
+
+ +

The problem a lot of people have with that output is that you cannot easily tell what +is a directory and what is a file. Some users prefer that ls add +a type identifier to each listing, like this:

+ + + + + +
+
+% ls -FC
+bin/   cdr/    dev/  home/  lost+found/  proc/  sbin/   tmp/  var/
+boot/  cdrom/  etc/  lib/   mnt/         root/  suncd/  usr/  vmlinuz
+
+
+ +

Directories get a slash at the end of the name, executable files get an asterisk at +the end of the name, and so on.

+ +

ls can also be used to get other statistics on files. For +example, to see the creation dates, owners, and permissions, you would look at a long +listing:

+ + + + + +
+
+% ls -l
+drwxr-xr-x   2 root     bin          4096 May  7 09:11 bin/
+drwxr-xr-x   2 root     root         4096 Feb 24 03:55 boot/
+drwxr-xr-x   2 root     root         4096 Feb 18 01:10 cdr/
+drwxr-xr-x  14 root     root         6144 Oct 23 18:37 cdrom/
+drwxr-xr-x   4 root     root        28672 Mar  5 18:01 dev/
+drwxr-xr-x  10 root     root         4096 Mar  8 03:32 etc/
+drwxr-xr-x   8 root     root         4096 Mar  8 03:31 home/
+drwxr-xr-x   3 root     root         4096 Jan 23 21:29 lib/
+drwxr-xr-x   2 root     root        16384 Nov  1 08:53 lost+found/
+drwxr-xr-x   2 root     root         4096 Oct  6 12:47 mnt/
+dr-xr-xr-x  62 root     root            0 Mar  4 15:32 proc/
+drwxr-x--x  12 root     root         4096 Feb 26 02:06 root/
+drwxr-xr-x   2 root     bin          4096 Feb 17 02:02 sbin/
+drwxr-xr-x   5 root     root         2048 Oct 25 10:51 suncd/
+drwxrwxrwt   4 root     root       487424 Mar  7 20:42 tmp/
+drwxr-xr-x  21 root     root         4096 Aug 24 03:04 usr/
+drwxr-xr-x  18 root     root         4096 Mar  8 03:32 var/
+
+
+ +

Suppose you want to get a listing of the hidden files in the current directory. This +command will do just that:

+ + + + + +
+
+% ls -a
+.              bin   cdrom  home        mnt   sbin   usr
+..             boot  dev    lib         proc  suncd  var
+.pwrchute_tmp  cdr   etc    lost+found  root  tmp    vmlinuz
+
+
+ +

Files beginning with a period (called dot files) are hidden when you run ls. You will only see them if you pass the -a option.

+ +

There are many more options that can be found in the online manual page. Don't forget +that you can combine options that you pass to ls.

+
+ +
+

10.1.2 cd

+ +

The cd command is used to change working directories. You +simply type cd followed by the path name to change to. Here are +some examples:

+ + + + + +
+
+darkstar:~$ cd /bin
+darkstar:/bin$ cd usr
+bash: cd: usr: No such file or directory
+darkstar:/bin$ cd /usr
+darkstar:/usr$ ls
+bin
+darkstar:/usr$ cd bin
+darkstar:/usr/bin$
+
+
+ +

Notice that without the preceding slash, it tries to change to a directory in the +current directory. Also executing cd with no options will move +you to your home directory.

+ +

The cd command is not like the other commands. It is a +builtin shell command. Shell builtins are discussed in Section 8.3.1. This may not make any +sense to you right now. Basically it means there is no man page for this command. +Instead, you have to use the shell help. Like this:

+ + + + + +
+
+% help cd
+
+
+ +

It will display the options for cd and how to use them.

+
+ +
+

10.1.3 pwd

+ +

The pwd command is used to show your current location. To use +the pwd command just type pwd. For +example:

+ + + + + +
+
+% cd /bin
+% pwd
+/bin
+% cd /usr
+% cd bin
+% pwd
+/usr/bin
+
+
+
+
+
+ + + + + -- cgit v1.2.3