Fifth Linux Lesson; First Saturday, hopefully only

Tagged as Linux

Written on 2007-06-16 20:39:00

Good afternoon netizens. Fear not, in spite of great adversity and personal difficulty I am here to bring you this week's Linux Lesson. It occurred to me that I was so foolish in our inaugural Linux Lesson that I taught you only the cd command and not the ls command. This is incredibly silly. These two should almost always be known in tandem. So with that in mind here we go.

Today's concept is finding files and getting file information via the terminal. Obviously, we've discussed things like permissions and file management on here before. However, rather than guessing where a file is or what permissions it has wouldn't you like to know? That's what we hope to cover today.

So, command number one. "ls" which stands for list. Clever, right? Maybe not but this handy little devil will solve most of your file searching and permission checking problems. For example, say you're looking for the "xorg.conf" file we mentioned a few weeks ago. If you think it's in /etc/X11 then you can do "cd /etc/X11" and then type "ls" or you could type "ls /etc/X11". Additionally, if you want to be shown hidden files you can append -a like so "ls -a /etc/X11" and to be shown permissions for files you can append -l like so "ls -l /etc/X11" or both in any order "ls -la /etc/X11" there are other options you can use but those are the two I find useful. When you check permissions with -l the output might look a little crazy to you. Probably something like this:
-rw-r--r-- 1 redline redline 1751 2007-02-04 15:21 aptrepository.asc
drwxr-xr-x 8 redline redline 4096 2007-06-14 19:01 Desktop
drwxr-xr-x 5 redline redline 4096 2007-04-17 22:48 doom3
lrwxrwxrwx 1 redline redline 36 2007-04-17 22:48 doom3-dedicated -> /home/redline/doom3//doom3-dedicated
-rw-r--r-- 1 redline redline 21145838 2007-04-17 22:41 doom3-linux-1.3.1.1304.x86.run
lrwxrwxrwx 1 redline redline 26 2007-02-04 11:38 Examples -> /usr/share/example-content
-rw-r--r-- 1 redline redline 1300 2007-03-17 02:04 file.txt
-rw-r--r-- 1 redline redline 1209 2007-03-17 02:03 file.txt~
-rw-r--r-- 1 redline redline 20017 2007-02-22 20:17 hs_err_pid5956.log
-rw-r--r-- 1 redline redline 0 2007-05-16 17:31 logfile.txt
-rw-r--r-- 1 redline redline 151552 2007-06-03 22:58 nautilus-debug-log.txt
drwxr-xr-x 3 redline redline 4096 2007-02-21 19:18 Photos
-rw-r--r-- 1 redline redline 44628 2007-02-27 08:48 python-gtkglext1_1.1.0-2feisty_i386.deb
drwxr-xr-x 2 redline redline 4096 2007-04-04 19:35 scripts
lrwxrwxrwx 1 redline redline 36 2007-04-12 09:11 TransGaming_Drive -> /home/redline/.cedega/Doom 3/c_drive
-rw-r--r-- 1 root root 684455936 2007-06-13 00:27 ubuntu-custom-live.iso
-rw-r--r-- 1 redline redline 3004403712 2007-05-31 20:21 windows.img
drwxr-xr-x 3 redline redline 4096 2007-04-22 00:57 workspace
-rw-r--r-- 1 redline redline 5368709120 2007-06-08 17:53 xubuntu-test.img
The permissions are found on the far left followed by the owner and group access file size, date last modified, and file name. Some of the files you'll notice have a -> and then another file listed. This is because they are something called a symlink which is effectively the same thing as a Windows shortcut. As for the permissions on the far left, I admit they look a little weird. Let me explain it this way, permissions are doled out separately on Unix-based systems to users, groups, and owners. Someone owns the file and generally speaking the owner has the right to choose who has access to it and whether they have read-only or read-write access as well as whether or not the file is executable. Groups are collections of users which share a given set of rights. Generally, you don't have to worry about groups. On your own computer you'll either own something or not. If you don't own it that means root (the superuser account) probably owns it in which case sudo comes in handy. Users are a more generic entity that probably only matters if people are remotely accessing a directory to upload files over the web but here I'm getting into things I don't know so I'll shut up. For our purposes and most beginning users purposes the only thing that matters is that you own the file and have read or write access to it. That can be seen in the permissions on the far left. The r stands for read, w for write, and x for executable. I believe that the first three are for the owner, the second three are for the group, and the third three are for users but don't quote me. We'll pick up here next week with some more permissions commands and a command to resolve the questions I've opened about permissions towards the end of this lesson. See you then.
comments powered by Disqus

Unless otherwise credited all material Creative Commons License by Brit Butler