Users and File Permissions

User, Groups, and Super Users

When logging in to a shell, you must login as an already created user on the system. Your user will have a "home" folder. Each file on the system is owned by a user and belongs to a certain group. Your user can belong to many different groups. Every Unix/Linux system also has a "super" user named root. Let's see who you are.

# whoami
# groups
# echo $HOME

Change to the root directory and issue a ls -l command. There are two columns that represent the user and group owner of each file and folder. The rwx sequence describes three sets of users (user, group, and other) and the rights (read, write, or execute) they have to a specific file or folder. There is one user that has super powers to modify any file or folder on the system: the root user.

There are many commands used to manage users which we will not be discussing. You can change the password of the current user if you want by using the passwd program. The su command can be used to switch users. If the su command is invoked with no username, the shell will ask for the root user's password. Oftentimes it is inadvisable to stay logged in as the root user, because of the awesome power that it wields. Instead, many GNU/Linux systems feature a special program, sudo, that lets an administrator user issue one command with root priveleges (sudo stands for "super user do").

File Permissions
Copyright The Regents of the University of California

Managing Files

Just like in a graphical user interface, the shell allows users the copy, move, or remove files and folders. Copying files requires that a user has read privileges on a file, and write privileges on the folder to copy it in to. Moving a file will delete the file at the original location and create a new copy in a new location. Strangely, renaming files is a matter of issuing the mv command. Both moving and removing files requires write privileges. Let's change directories to the current user's home directory (abbreviated ~/) and do some file manipulation.

# cd ~/
# touch file1 file2 file3
# ls -l
# cp file1 file1new
# ls -l
# mv file2 file2new
# ls -l
# rm file3
# ls -l
# rm file*
# ls -l

The last rm command used the "glob" operator, denoted by a *. In a shell, the glob operator stands for any sequence of characters, and is useful for identifying groups of files. In the next page, several other special features of the shell are discussed.

Last modified: Tuesday, 16 June 2020, 3:41 AM