Tag Info

Hot answers tagged

52

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 ...


31

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 ...


29

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 ...


22

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 ...


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 ...


13

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 ...


12

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). ...


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 ...


9

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. ...


9

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 ...


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 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 ...


8

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.


8

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 cfengine3 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 combine this ...


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

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 ...


7

A process in S state is usually in a blocking system call, such as reading or writing to a file or the network, or waiting for another called program to finish. You can use strace -p pid to find out which system call is currently happening, it'll produce output like write(1, "foobar"..., 4096 which means that the process is trying to write 4096 bytes ...


7

To rename a file, write permissions to the file don't matter, renaming a file is a change to the directory, not the file. That's changing the directory entry to have a different name pointing to the file. So all you need to do is change the permissions of the directory. For instance: chown root: . chmod 755 . That will prevent users from renaming files ...


6

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 ...


6

If you run man ps then type /SpaceShift+CSpaceEnter, you should see this line. C pcpu cpu utilization but that's under the OBSOLETE SORT KEYS header, so is not what we're looking for. Press n to find the next match: c C processor utilization. Currently, this is the integer value of the percent ...


6

I know a solution, but it requires 'root' privilege sadly. Anyway, you might still found it usefull: sudo lshw -class disk -class storage For each device it will print the logical name (e.g. /dev/sda) and bus info which in case of USB device would be something like 'usb@1:2'. Sample output: [...] *-storage description: SATA controller ...


6

There are a few ways to tell without root privileges, many of them tricky/hacky: Using /dev/disk/by-id: find /dev/disk/by-id/ -lname '*sdX' If this responds with something like /dev/disk/by-id/usb-blah-blah-blah, then it's a USB disk. Other prefixes include ata, dm, memstick, scsi, etc. Using /dev/disk/by-path isn't significantly different: find ...


6

In the simplest scenario where each distribution has its own partition and everything necessary for the system to run is within that partition (you don't have separate partitions for /usr for example), you can do this with chroot: I assume you have the partitions mounted somewhere, let's say they're at /Debian and /Fedora. Set up a chroot environment: sudo ...


5

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, or send this to ...


5

Enter "you damn kids" mode. Your tools should help you do your job more efficiently, without preventing you from understanding what is going on. Really, RH 4 is not that old, and mostly similar to what is around today. It might not have the latest and greatest, but should be sufficient to do what you need (what is it that you need). Rant over. On ...


5

The Linux Advanced Routing & Traffic Control HOWTO has a section describing to solve the problem. The key step to balance traffic between the two routes is to give them both a weight. ip route add default scope global \ nexthop via 192.168.0.1 dev eth1 weight 1 \ nexthop via 192.168.1.1 dev eth0 weight 1


5

The practice is not to create one user and group per application, but per service. That is, programs that are executed by a local user don't need to be installed as a user other than root. It's daemons, programs running in the background and that execute requests coming through the network or other communication means, that should run as a dedicated user. ...


5

If your OS is supporting dtrace, that a simple script, shellsnoop, should allow you to monitor everything typed/printed on a given tty. If you are running Linux, ttysnoop used to do a similar thing but needed an intrusive configuration as a prerequiste and is AFAIK no more supported with current kernels anyway so won't help in your case. There are more or ...



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