File System Permissions
Linux is file-centric, which means that most of what Linux offers to applications and users is done through a set of files. Security in Linux is also file-centric and is based almost entirely on the permissions placed on a file or directory. NTFS in Windows offers an advanced permission facility that's based on ACLs. In theory, Linux also supports ACLs, but often this support isn't enabled or even compiled into the Linux kernel. Because Linux's ACL support is inconsistent, I instead concentrate on the more traditional Linux permission model.
Linux provides three types of permissions that you can apply to a file: read, write, and execute (r, w, and x). In addition, you can set permissions for three types of users: owner, group, and world (u, g, and o). Owner is just that, the file's owner; group is the "group owner;" and world is the set of users that aren't the owner or in the group. World is basically a catch-all, similar to Everyone in Windows.
As I mentioned earlier, you use the chgrp and chmod commands to set group permissions. For example, to restrict control of the /files/students directory to only the users in the students group, you'd run the commands
# chgrp -R students /files/students
# chmod -R u=rwx,g=rwx /files/students
The −R option specifies that chgrp and chmod should recursively apply the changes, and the u=rwx,g=rwx field translates to "the owner will have read, write, and execute permissions, and the group will also have read, write, and execute permissions."
To let only a file's owner access the file, you'd run chmod as follows:
# chmod u=rwx /user/file
In Windows, the equivalent command is Cacls:
C:\ cacls c:\user\file /e /p bob:f
/e specifies that the Cacls command will edit an ACL instead of replacing it, and /p bob:f grants Bob full permissions to c:\user\file.
To let both the owner and anyone in the group access the file, you'd enter
# chmod u=rwx,g=rwx /user/file
Again, remember that in Linux you can assign permissions only to one group, whereas with NTFS you can specify rights to multiple groups by using ACLs. (Some file systems in Linux support ACLs; they just aren't used by default.) You can find more information about chmod and chgrp by reading the commands' man pages. (For more information about man pages, see "Linux's Online Help.")
Networking
Networking is an integral part of Linuxso much so that, as in Windows, it's virtually impossible to remove the networking components without breaking the OS (but not nearly as difficult to remove the Web browser!). In Windows, when you want to manage networking, you must define and configure NICs by running the Network Connections Control Panel applet. You can also automate the process of configuring networking in Windows by using the Netsh command. Like Windows, Linux provides command-line and GUI tools to manage networking.
Let's walk through configuring a Linux system for networking. First, you must determine whether Linux knows about your NIC. The easiest method to accomplish this is to run the ifconfig command, which tells you whether the OS is providing access to the NIC:
# ifconfig eth0
The eth0 device is simply the first NIC that Linux sees. In Windows, this device is called "Local Area Connection" when you view it in the Network Configuration applet or via the Windows Ipconfig command. (The closest Windows equivalent of ifconfig is ipconfig /all.) After you run ifconfig, you'll see output on screen similar to that in Figure 2. Now that you know that the NIC is working, you can configure itagain by running ifconfig:
# ifconfig eth0 192.168.1.10
netmask 255.255.255.0
(The command wraps to two lines here because of space constraints.) Running this command displays the eth0 interface (i.e., the first NIC on the system), which has the IP address 192.168.1.10 and a subnet mask of 255.255.255.0. Linux also automatically adds a network route to the routing table, so that you can now ping other hosts on the LAN, by running the command
# ping -c 1 192.168.1.1
The −c option specifies that the Ping command pings the remote server only once. The command then displays the output that Figure 3 shows (several lines in Figure 3 wrap because of space constraints). In Red Hat, you can automate the network configuration process I've just describedand ensure that the configuration is maintained after a rebootsimply by running the command
# netconfig
If you want to connect the system to the Internet, you must perform two more steps: Configure a default router, and configure your DNS servers. To configure the default router, use the route command (which is similar to the Windows route command):
# route add -net default
gw 192.168.1.1
This commandwhich wraps to two lines herespecifies that we're adding a route to a network (rather than just to a host), that the network is "default" (the value that's used when specifying a default router), and that the default router (gw) is 192.168.1.1.
Finally, you add your DNS servers to the /etc/resolv.conf file, which configures the server's DNS resolver, by using the following syntax:
nameserver dns1.example.com
nameserver dns2.example.com
As I mentioned, instead of performing the network configuration manually, you can automate this process by running the netconfig command. Netconfig lets you set up your networking to use either DHCP or a static IP address. It works the same as the Windows Add Network wizard. Although simply using netconfig is far easier than the process I just described, by learning exactly what netconfig is doing you have a better understanding of how Linux networking works. You'll probably find it helpful to investigate other Linux commands that are also available in Windows, such as netstat and nslookup.
Installing and Managing Software
Software management in Linux can often be at least as difficult as it is for Windows users. In Linux, software is distributed in various ways. Most distributions, such as Red Hat with Red Hat Package Manager (RPM), have their own package format. RPM packages are well supported across most Linux distributions and are the closest thing to a true package standard in the Linux world.
An actual RPM file is a single file archive that contains all the software and installation scripts needed to install an application, much like setup.exe or an .msi file in Windows. To install an RPM, you run the rpm command along with the RPM file as an argument:
# rpm -i program.rpm
The −i specifies that you want to install program.rpm. To remove the program you just installed from the Linux system, run the rpm command and specify the −e (extract) option with the program name:
# rpm -e program
To determine whether a program is installed, run the rpm command and specify the −q (query) option with the program name:
# rpm -q program
This procedure should feel similar to using the Windows Add or Remove Programs applet. Most Linux systems, such as RHES, provide a GUI front end for RPM, so the similarity is even closer.
Linux differs from Windows in that many distributed Linux applications don't use a standardized packaging format. Typically, these types of applications are distributed in source-code form, and you must compile and install them yourself. Fortunately, most applications that are installed from source code follow the same basic steps in their installation:
- Extract the files from the archive by running the tar command (the tar command copies files to or restores files from an archive):
# tar xfz program.tgz
- Change the current directory to the directory just created when tar extracted files from program.tgz:
# cd program/
- Compile the application by running the following commands:
# ./configure
# make
# make install
At this point, you're finished installing the application. Because this application didn't use a package manager such as RPM, it might be difficult to remove the application. Typically, you'd first try to run the command
make uninstall
but this method fails more often than not. The only other option would be to manually delete the installed files or to use software that manages applications that are installed from source code.
Go Forth into Linux
Linux and Windows system administrators perform the same sorts of tasks: They manage users, install and remove software, troubleshoot bad network connections, and of course, try to take a break now and then. When you find yourself called on to manage a Linux system in your Windows environment, you'll have some familiarity with essential commands and procedures that you can use to get up to speed in Linux system administration.
Anonymous User October 29, 2004