Tag Info

Hot answers tagged

56

There's probably an easier way, but I do this: See who's logged into your machine -- use who or w: > who mmrozek tty1 Aug 17 10:03 mmrozek pts/3 Aug 17 10:09 (:pts/2:S.0) Look up the process ID of the shell their TTY is connected to: > ps t PID TTY STAT TIME COMMAND 30737 pts/3 Ss 0:00 zsh Laugh at their ...


40

The devil is in the details, in the useradd man page (you can see that by issuing man 8 useradd): -u, --uid UID The numerical value of the user's ID. This value must be unique, unless the -o option is used. The value must be non-negative. The default is to use the smallest ID value greater than or equal to UID_MIN and greater ...


34

Try usermod --move-home --login <new-login-name> --home <new-home-dir> <old-login-name> The --move-home option moves the old home directory's contents to the new one given by the --home option which is created if it doesn't already exist. If you want the primary user group to match the new-login-name, add --gid <new-login-name> to ...


30

For the same reasons why each daemon should have minimal rights. Apache can run as root. It is designed to perform one task and surely nothing bad can happen? But assume apache is not bug-free. Bugs are discovered from time to time. Sometimes it can even be arbitrary code execution or similar. Now with apache running as root, it can access anything — for ...


24

Add the user to the wheel group: gpasswd wheel -a username I use gpasswd because not all versions of usermod have an easy way to add the user to a group without changing all the users' groups. However, on any recent Fedora, usermod username -a -G wheel should have the same effect. You could also use the system-config-users GUI, of course. If you are ...


24

You can also ride a motorcycle in the nude, and nothing may happen. But I bet you'd feel better if you had when you crash the bike...


21

As Micheal already pointed out, you can use who to find out who's logged in. However if they have multiple processes, there's a more convenient way than killing each process individually: you can use killall -u username to kill all processes by that user.


17

The harsh truth is that nothing can protect you from your own stupidity. There's no DWIM (do what I mean) interface. The computer can't tell the difference between what is intentional and what is accidental. No matter how much abstraction you pile on the wrong stray command can destroy it all. The simple answer is to slow down and pay attention to what ...


14

To avoid a mistaken rm -rf, do not type rm -rf. If you need to delete a directory tree, I recommend the following workflow: If necessary, change to the parent of the directory you want to delete. mv directory-to-delete DELETE Explore DELETE and check that it is indeed what you wanted to delete rm -rf DELETE Never call rm -rf with an argument other than ...


13

While it's possible to rename a user, and usermod will do some of the job, this is quite likely to cause trouble. Here's a list of places where the user name may appear; I do not claim that this list is exhaustive. The user entry in /etc/passwd and related files (e.g. /etc/shadow, /etc/master.passwd). Group entries in /etc/group (and /etc/gshadow). ...


12

The UID of the deleted user was reused by the new user, and filesystems use a UID for ownership, not a username.


11

Apart from the obvious point of security, it is clear you've never hosed your system by mistyping a command in the shell or a lapsus. If it happens, you'll understand why people freak out about it. And then you will cry in horror, and also realize that it was a highly educational experience, but you're not getting your system back anyway. A thought: if ...


10

Necromancy! I appreciate the humor of the accepted answer, but professionally I can't advocate it. The most graceful method I'm aware of is to send a -HUP to the shell to simulate a user hangup. You can send this to the user's idle sshd to simulate their connection being lost, which triggers a cleanup of the entire shell environment (including child ...


10

Logout the user 'username': skill -KILL -u username See man skill


10

The kernel documentation provides a general coverage of cgroups with examples. The cgroups-bin package (which depends on libcgroup1) already provided by the distribution should be fine. Configuration is done by editing the following two files: /etc/cgconfig.conf Used by libcgroup to define control groups, their parameters and mount points. ...


10

The usermod command will allow you to change a user's primary group, supplementary group or a number of other attributes. The -g switch controls the primary group. For your other questions... 1 - If you specify a group, groupname, that does not exist during the useradd stage, you will receive an error - useradd: unknown group groupname 2 - The groupadd ...


10

Run your installation in a virtual machine. Take a snapshot of a known good state. Take snapshots before doing anything risky. Do almost nothing in the host environment. If you screw up, connect to the host environment and restore the snapshot.


10

Contrary to what their most common use would lead you to think, su and sudo are not just meant for logging in (or performing actions) as root. su allows you to switch your identity with that of someone else. For this reason, when you type su, the system needs to verify that you have the credentials for the target user you're trying to change into. sudo is ...


9

Other useful command is pkill here pkill -u username && pkill -9 -u username. killall have disadvantage that on Solaris IIRC it means something completely different - also pkill have slightly more advanced options.


9

Matt's answer is quite correct but misses the historical context that when UNIX systems were first brought into larger data centers "operator" was usually the actual job title for the staff performing simple routine tasks on the systems.


9

The concept of operators origins from the second generation of computers. Back at that time, programmers used to write code on punch cards, then deliver the cards to an operator - professional staff with access to the insanely expensive mainframe machine. The operator was responsible for putting the cards on the machine for execution. When the execution was ...


9

The Unix Rosetta Stone is a good resource for this kind of questions. It mentions a few alternatives for lsof (see below). Do not however that lsof is the de facto standard application for what it does. If all you want is to find the process ID(s) that have a particular file open, then you can use fuser on any POSIX-compliant system. On operating systems ...


9

It depends what exactly you need and what you are looking for. But in general there exists multiple solutions for "configuration management like: puppet chef cfengine ansible salt etc. I personally would recommend puppet as it has a big community and a lot of external provided recipes. This allows you to configure and manage systems automatically. If you ...


9

"A package manager is working" means that something is holding a lock on /var/lib/dpkg/lock and/or/var /cache/apt/archives/lock. You can find out which process this is with the fuser command: dennis@lightning:~$ sudo fuser /var/lib/dpkg/lock /var/cache/apt/archives/lock /var/lib/dpkg/lock: 18049 /var/cache/apt/archives/lock: 18049 dennis@lightning:~$ cat ...


8

The operator user was traditionally there for simple maintenance, so usually has unrestricted read access to disks (by also being in the operator group) to perform dumps / backups. That way a backup can be taken without requiring root pw.


8

You can't use crontab like that. Use man crontab to read about the correct way of calling this utility. You'll want to use crontab -e to edit the current user's cron entries (you can add/modify/remove lines). Use crontab -l to see the current list of configured tasks. As for seeing other user's crontabs, that's not possible without being root on default ...


8

It's the fd to the master side of the pseudo-terminal in the terminal emulator that you want to monitor if you want to see what's displayed on it. That master fd is what simulates the wire that goes to a real terminal. What xterm writes on it is the characters generated from the key you press. What it reads from it is what it displays. For instance, on ...


7

You should understand how to use common(ish) unix tools. vim may have changed between redhat 4 and redhat 300, but I bet you vi is the same (even if they are using vim as a replacement for vi, the vi commands will work as expected). The package tools may not be familiar to you, but I bet you can still download a tgz file, ./configure, make, sudo make ...


7

Use su: $ su -c command or $ su # command # exit In either case, you will be prompted for the root password. For more information, see the manual page.



Only top voted, non community-wiki answers of a minimum length are eligible