Flag | Usage |
---|---|
-v variableName | unset variableName and remove it from the environment
read-only variables can not be unset
|
Flag | Usage |
---|---|
-l --lazy |
lazy unmount : detach the filesystem from the file hierarchy now, and clean up all references to this filesystem as soon as it is not busy anymore
|
Flag | Usage |
---|---|
e archive.rar | extract all files from archive.rar into the current directory.
Files with identical names that belong to different sub-directories inside the archive will collide once extracted (unrar will prompt whether to overwrite / rename / ...). Consider x to avoid this. |
l archive.rar | list contents of archive.rar (and see if it has sub-directories) |
x archive.rar | extract archive.rar respecting its internal tree structure |
rw-r--r--
)rwxr-xr-x
)Mask value | Permissions for ... | Who can ... ? | ||
---|---|---|---|---|
files | directories | read | write | |
022 | rw-r--r-- |
rwxr-xr-x |
everybody | owner only |
077 | rw------- |
rwx------ |
owner only | owner only |
umask
/etc/profile /etc/bashrc ~/.bashrc 2>/dev/nullumask : 022 drwxr-xr-x 2 stuart users 1024 Apr 18 10:35 myDir -rw-r--r-- 1 stuart users 0 Apr 18 10:35 myFile umask : 044 permissions below don't work in "real life", this example is for demonstration only drwx-wx-wx 2 stuart users 1024 Apr 18 10:35 myDir -rw--w--w- 1 stuart users 0 Apr 18 10:35 myFile umask : 055 same comment as above : for demo only, not for real life drwx-w--w- 2 stuart users 1024 Apr 18 10:35 myDir -rw--w--w- 1 stuart users 0 Apr 18 10:35 myFile umask : 077 drwx------ 2 stuart users 1024 Apr 18 10:35 myDir -rw------- 1 stuart users 0 Apr 18 10:35 myFile
update-rc.d has been obsoleted by systemctl and systemd.
install and remove System-V style init script linksA common system administration error is to delete the /etc/rcrunlevel.d/[SK]NNname links with the thought that this will "disable" the service, i.e., that this will prevent the service from being started.
However, if all links have been deleted then the next time the package is upgraded, the package's postinst script will run update-rc.d again and this will reinstall links at their factory default locations.
The correct way to disable services is to configure the service as stopped in all runlevels in which it is started by default. In the System-V init system, this means renaming the service's symbolic links from S to K. To do so :
update-alternatives is used to maintain the symbolic links (found in /etc/alternatives/) determining default commands
It is possible for several programs fulfilling similar functions (e.g. text editors) to be installed on a single system at the same time. This gives choice to the users, allowing each to use a different editor, but makes it difficult for a program to make a good choice of editor to invoke if the user has not specified a particular preference.
The alternatives system aims to solve this problem. A generic name in the filesystem is shared by all files providing interchangeable functionality :
lrwxrwxrwx 1 root root 24 Oct 11 15:47 /usr/bin/editor -> /etc/alternatives/editor*
lrwxrwxrwx 1 root root 18 Mar 24 15:04 /etc/alternatives/editor -> /usr/bin/vim.basic*
update-alternatives is generally automatically executed when installing / removing software on the system.
alternatives are handled by groups (for instance: for a binary and the associated man pages) known as link groups, so that they can (should!) be updated all at once : updating the master of a link group triggers the update of the slave link(s).
Each link group is, at any given time, in one of two modes :
editor - manual mode link best version is /usr/bin/vim link currently points to /usr/bin/vim.basic current setting link editor is /usr/bin/editor slave editor.1.gz is /usr/share/man/man1/editor.1.gz symlinks /usr/share/man/man1/editor.1.gz -> /etc/alternatives/editor.1.gz -> /usr/share/man/man1/vim.1.gz slave editor.fr.1.gz is /usr/share/man/fr/man1/editor.1.gz /bin/nano - priority 40 slave editor.1.gz: /usr/share/man/man1/nano.1.gz /usr/bin/emacs24 - priority 0 slave editor.1.gz: /usr/share/man/man1/emacs.emacs24.1.gz /usr/bin/vim - priority 50 /usr/bin/vim.basic - priority 30 slave editor.1.gz: /usr/share/man/man1/vim.1.gz slave editor.fr.1.gz: /usr/share/man/fr/man1/vim.1.gz /usr/bin/vim.tiny - priority 15 slave editor.1.gz: /usr/share/man/man1/vim.1.gz slave editor.fr.1.gz: /usr/share/man/fr/man1/vim.1.gz
update-alternatives: using /usr/bin/vim to provide /usr/bin/editor (editor) in auto mode
editor - auto mode
link best version is /usr/bin/vim
link currently points to /usr/bin/vim
link editor is /usr/bin/editor
There are 5 choices for the alternative editor (providing /usr/bin/editor). Selection Path Priority Status ------------------------------------------------------------ * 0 /usr/bin/vim 50 auto mode 1 /bin/nano 40 manual mode 2 /usr/bin/emacs24 0 manual mode 3 /usr/bin/vim 50 manual mode 4 /usr/bin/vim.basic 30 manual mode 5 /usr/bin/vim.tiny 15 manual mode Press <enter> to keep the current choice[*], or type selection number: 1 update-alternatives: using /bin/nano to provide /usr/bin/editor (editor) in manual mode
update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/editor (editor) in manual mode
editor - manual mode
link best version is /usr/bin/vim
link currently points to /usr/bin/vim.basic
link editor is /usr/bin/editor
Flag | Usage |
---|---|
-a | (only with -G) append specified group to group list |
-e expireDate --expiredate expireDate |
Specify the account expiration date (format : YYYY-MM-DD) : after this date :
|
-g | change the user's initial group |
-G | change the user's secondary Group(s) |
-L bob --lock bob |
|
-p encryptedPassword --password encryptedPassword |
store encryptedPassword into /etc/shadow |
-s otherShell | change the user's shell to otherShell |
-U bob --unlock bob |
|
Flag | Usage |
---|---|
-r | delete :
|
Create a new user or update default "new user" information.
/usr/sbin/useradd: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, BuildID[sha1]=493f6bd6c372a7a9a93e26de333ee303d3ed9e53, stripped /usr/sbin/adduser: Perl script text executable
Flag | Usage |
---|---|
-d /home/userName --home /home/userName |
The new user will be created using /home/userName as the user's login directory. |
-D -D [options...] |
Display Default values of account settings (group, home dir, shell, ...) update Default value of settings field |
--disabled-login | The account will be created but will be disabled until a password is set. adduser-only option |
--disabled-password | Like --disabled-login, but logins are still possible (for example using SSH keys) but not using password authentication since no password is set.
|
-g value --gid value |
|
-G group1,group2,,groupn | set user's secondary Group(s) |
-m | create user's home directory if it doesn't exist yet |
-o --non-unique |
|
|
create a system account
useradd will not create a home directory for such a user (regardless of the default setting in /etc/login.defs), explicitly specify -m to do so.
|
-s userShell | specify the user's shell
|
-u UID --uid UID | specify the user's ID (numerical value). This value must be :
This value may also become the GID under some special circumstances.
|
!
right after the login name in /etc/shadow) To enable it, unlock the account (blank password !!!) then login as this new user and set a password. (or, as root : passwd bob)useradd -G admins,ftp,www,developers stuart
groups are comma-separated, without space.Flag | Usage |
---|---|
-c --count | prefix lines with the count of occurrences |
-d --repeated | only print duplicate lines |
-u --unique | only print unique lines |
select distinct ... ;
(nothing)Nothing found because duplicates are not adjacent
aaa
aaa
aaa bbb aaa ccc
bbb ccc
aaa bbb ccc
User limits - limit the use of system-wide resources.
ulimit provides control over the resources available to the shell and to processes started by it, on systems that allow such control.
The soft limit is the value that the kernel enforces for the corresponding resource. The hard limit acts as a ceiling for the soft limit.
An unprivileged process may only set its soft limit to a value in the range from 0 up to the hard limit, and (irreversibly) lower its hard limit. A privileged process may make arbitrary changes to either limit value.
If limit is given, it is the new value of the specified resource. Otherwise, the current value of the soft limit for the specified resource is printed, unless the -H option is supplied.
A command returning something like cannot : Resource temporarily unavailable may be the sign of hitting one of these limits.
A hard limit can only be raised by root (any process can lower it). So it is useful for security: a non-root process cannot overstep a hard limit. But it's inconvenient in that a non-root process can't have a lower limit than its children.
A soft limit can be changed by the process at any time (to the extent permitted by the hard limit unless running as root of course). So it's convenient as long as processes cooperate, but no good for security.
Flag | Usage |
---|---|
-a | Report all current limits. This can be used to check updating a limit was successful |
-Hx -Hx value |
Report the hard limit associated with the resource x Set the hard limit associated with the resource x to value |
-Sx -Sx value |
Report the soft limit associated with the resource x Set the soft limit associated with the resource x to value |
-n | The maximum number of open file descriptors |