Search and substitute
You can easily search for data in the buffer using the vim search command. To enter a search string, press the forward slash (/) key.
The substitute command allows you to quickly replace (substitute) one word for another in the text. To get to the substitute command you must be in command line mode.
The format for the substitute command is:
There are a few modifications you can make to the substitute command to substitute more than one occurrence of the text:
:s/old/new/g to replace all occurrences of old in a line
:#,#s/old/new/g to replace all occurrences of old between two line numbers
:%s/old/new/g to replace all occurrences of old in the entire file
:%s/old/new/gc to replace all occurrences of old in the entire file, but prompt for each occurrence.
Linux assigns the file permissions of the new file using your default UID and GID. To allow others access to the file, you need to either change the security permissions for the everyone security group or assign the file a different default group that contains other users.
This can be a pain in a large environment if you want to create and share documents among several people. Fortunately, there’s a simple solution for how to solve this problem.
There are three additional bits of information that Linux stores for each file and directory.
The set user id (SUID): When a file is executed by a user, the program runs under the permissions of the file owner.
The set group id (SGID): For a file, the program runs under the permissions of the file group. For a directory, new files created in the directory use the directory group as the default group.
The sticky bit: The file remains (sticks) in memory after the process ends.
The SGID bit is important for sharing files. By enabling the SGID bit, you can force all new files created in a shared directory to be owned by the directory’s group and now the individual user’s group.
The SGID is set using the chmod command. It’s added to the beginning of the standard three digit octal value (making a four-digit octal value), or you can use the symbol s in symbolic mode.
The umask command
The umask command shows and sets the default permissions:
The umask value is just that, a mask. It masks out the permissions you don’t want to give.The umask value is subtracted from the full permission set for an object. The full permission for a file is mode 666 (read/write permission for all), but for a directory it’s 777 (read/write/execute permission for all).
Thus, in the example, the file starts out with permissions 666, and the umask of 022 is applied, leaving a file permission of 644. The umask value is normally set in the /etc/profile startup file.
The pam_time module is used as an account module-type. The pam_time module does not accept arguments. It instead uses the /etc/security/time.conf file to get information related to login time and location restrictions. There are two important points concerning the /etc/security/time.conf.
The /etc/security/time.conf file restricts access by time and location when used with pam_time.
Each line in /etc/security/time.conf file is called a rule.
Each rule uses the following syntax:
services;ttys;users;times
/etc/skel directory
The system will copy the contents of the /etc/skel directory to the user’s HOME directory.
The useradd command allows an administrator to create a default HOME directory configuration, then uses that as a template to create the new user’s HOME directory. This allows you to place default files for the system in every new user’s HOME directory automatically. On my Linux system, the /etc/skel directory has the following files.
root@dell:/etc/skel# ls -ld *
drwxr-xr-x 2 buddy buddy 4096 Oct 11 2008 Desktop
drwxr-xr-x 2 buddy buddy 4096 Mar 4 2009 Documents
drwxr-xr-x 2 buddy buddy 4096 Mar 4 2009 Download
drwxr-xr-x 2 buddy buddy 4096 Mar 4 2009 Music
drwxr-xr-x 2 buddy buddy 4096 Mar 4 2009 Pictures
drwxr-xr-x 2 buddy buddy 4096 Mar 4 2009 Public
drwxr-xr-x 2 buddy buddy 4096 Mar 4 2009 Templates
drwxr-xr-x 2 buddy buddy 4096 Mar 4 2009 Videos