Unix is a multitasking, multi-user computer operating system originally developed in 1969 by a group of AT&T employees at Bell Labs.

learn more… | top users | synonyms

158
votes
11answers
47k views

Can I nohup/screen an already-started process?

I'm doing some test-runs of long-running data migration scripts, over SSH. Let's say I start running a script around 4 PM; now, 6 PM rolls around, and I'm cursing myself for not doing this all in ...
94
votes
3answers
30k views

What is the difference between double and single square brackets in bash?

I just wondered what exactly the difference between [[ $STRING != foo ]] and [ $STRING != foo ] is, apart from that the latter is posix-compliant, found in sh and the former is an extension ...
67
votes
15answers
66k views

Copying a large directory tree locally? cp or rsync?

I have to copy a large directory tree, about 1.8 TB. It's all local. Out of habit I'd use rsync, however I wonder if there's much point, and if I should rather use cp. I'm worried about permissions ...
57
votes
12answers
50k views

In my /etc/hosts/ file on Linux/OSX how do I do a wildcard subdomain?

I need to test sub-domains on my localhost. How can I effectively have this result of adding *.localhost.com to m /etc/hosts/ file? If it's not possible, how do I work around this problem? I need ...
54
votes
6answers
60k views

How to forcibly close a socket in TIME_WAIT?

I run a particular program on linux which sometimes crashes. If you open it quickly after that, it listens on socket 49201 instead of 49200 as it did the first time. netstat reveals that 49200 is in ...
48
votes
9answers
33k views

Is it possible to detach a process from its terminal? (Or, “I should have used screen!”) [duplicate]

Possible Duplicate: Can I nohup/screen an already-started process? On Unix (specifically, Linux), I've started a job in a regular ssh->bash session. I'd like to leave work soon, but I now ...
44
votes
3answers
4k views

What is the difference between a soft (symbolic) link and a hard link?

I hear that you can now create soft links in Vista too. So, what is the difference between a soft (symbolic) link and a hard link on UNIX/Linux/Vista? Are there advantages of using one over the ...
41
votes
8answers
25k views

Environment variables of a running process on Unix?

This is to troubleshoot some problems related to environment variables .. On Windows, I could do this by using tool such as ProcessExplorer to select particular process and view values of each ...
38
votes
15answers
8k views

Favorite rsync tips and tricks

The more I use rsync the more I realise that it's a swiss army knife of file transfer. There are so many options. I recently found out that you can go --remove-source-files and it'll delete a file ...
37
votes
10answers
8k views

Learning to compile things from source (on Unix/Linux/OSX)

While I install software from packages (MacPorts / apt-get) where-ever possible, I often find myself needing to compile packages from source. ./configure && make && sudo make install ...
37
votes
1answer
16k views

How do I change my private key passphrase?

I have an existing public/private key pair, the private key is password protected, the encryption may be either RSA or DSA. These keys are the kind you generate with ssh-keygen and generally store ...
35
votes
52answers
5k views

Favorite Unix command line aliases? [closed]

What are your favorite command line aliases (bash/sh/tcsh) aliases? Here are a few of mine. alias lsr='ls -lrt' alias gon='cd $HOME/Notes' alias devdb='mysql -h dev --user=x --password=secret ...
35
votes
2answers
4k views

Why do I have to edit /etc/sudoers with visudo?

I've noticed that the sudoers file and cron config files act in a special way compared to other config files on Linux. They need to be edited with a special wrapper rather than any text editor. Why is ...
34
votes
30answers
5k views

Command line safety tricks [closed]

Command line and scripting is dangerous. Make a little typo with rm -rf and you are in a world of hurt. Confuse prod with stage in the name of the database while running an import script and you are ...
34
votes
4answers
15k views

Drawbacks of mounting a filesystem with noatime?

Having every file be updated just when accessing them sounds like a waste. What's the catch with mounting a file system with the noatime option. What kind of applications/servers relies on the access ...
33
votes
42answers
6k views

Tools a Unix administrator cannot live without [closed]

After administering Unix or Unix-like servers, what tools (command-line preferably) do you feel you cannot live without?
29
votes
6answers
18k views

What does 'set -e' do, and why might it be considered dangerous?

This question has appeared on a pre-interview quiz and it's making me crazy. Can anyone answer this and put me at ease? The quiz has no reference to a particular shell but the job description is for a ...
29
votes
8answers
20k views

What is a zombie process and how do I kill it?

Virtual Shotguns?
28
votes
11answers
937 views

Best practices for keeping UNIX packages up to date?

How do you keep your servers up to date? When using a package manager like Aptitude, do you keep an upgrade / install history, and if so, how do you do it? When installing or upgrading packages on ...
26
votes
4answers
20k views

How to convert text file from Windows line breaks to Unix ones on Unix/Linux?

Is there a quick way to convert text file from Unix line breaks to Windows ones in Unix environment? I thought there could be a standard utility.
26
votes
6answers
6k views

How to determine the “age” of a linux system since installation?

any ideas please ? first off I thought that I could easily check the timestamp of particular files, but then I realized that it wouldn't be so easy when I saw timestamps like 1991 :-)
25
votes
9answers
24k views

How to reduce memory usage on a Unix webserver

I'm currently using a Joyent Accelerator to host my webapps, and it's working fine, however I need to reduce costs so I'm downgrading my current plan and that imposes some new memory limits (256M rss, ...
23
votes
3answers
2k views

Why is Linux reporting “free” memory strangely?

This is a canonical question about how Unix operating systems report memory usage. Similar Questions: Server refuses to use swap partition Memory Usage in LINUX I have production ...
23
votes
6answers
36k views

How to get e-mail from (failed) cron-jobs in Ubuntu?

I create cron-jobs in Ubuntu by placing the executable in one of /etc/cron.{daily,hourly,monthly,weekly}. There are lots of directories starting with cron: kent@rat:~$ ls -ld /etc/cron* drwxr-xr-x 2 ...
23
votes
6answers
6k views

Meaning of directories on Unix and Unix like systems

I've been using Linux for a couple of years now but I still haven't figured out what the origin or meaning of some the directory names are on Unix and Unix like systems. E.g. what does etc stand for ...
21
votes
5answers
4k views

What do these abbreviations stand for?

Some directories are easy to understand the meaning /usr /bin ... But for the next ones, I have no idea. /etc /opt opt for optional? etc for electronic t...... configuration (no idea for t) I ...
21
votes
5answers
2k views

Can a program tell it is being run under sudo?

I have a program that should behave differently if it is being run under "sudo". Is there a way it can find out if it was run under sudo? Update: Someone asked why would I want to do this. In this ...
20
votes
10answers
3k views

I just did a chmod -x chmod

So I did a chmod -x chmod. How I can fix this problem? How do I give execute rights back to chmod?
20
votes
4answers
3k views

In tail -f, how do I filter out stuff that has certain keywords?

I want to tail -f my logs. However, I want to filter out everything that has the words: "ELB", "Pingdom", "Health"
20
votes
6answers
8k views

What is a good solution to encrypt some files in unix?

I am looking for a utility to encrypt certain directories in Linux. I am not looking for any full disk encryption services, but simply to encrypt a few directories for the purposes of storing files in ...
20
votes
5answers
18k views

When does /tmp get cleared?

I'm taking to putting various files in /tmp, and I wondered what the rules on deleting them are? I'm imagining it's different for different distributions, and I'm particularly interested in Ubuntu ...
20
votes
10answers
8k views

Alternative to Daemontools (djbtools) to supervise unix processes?

I've used Daemontools to provide a simple and reliable way to supervise Unix services on my servers. It works well, but it requires a different way of thinking (The DJB Way) and some common complaints ...
19
votes
5answers
2k views

Turning off atime on a filesystem

I am setting up a mongoDB replica set and one of the first things I am suppose to do is turn off atime on the file system. After researching this a bit, I am not opposed to doing this, but I have to ...
18
votes
23answers
26k views

Finding the Public IP address in a shell script

I can find my IP address using ifconfig or hostname -i command. But how do I find my Public IP? (I have a static public IP but I want to find it out using unix command)
18
votes
4answers
15k views

How to sort ps output by process start time?

Is there a way to sort ps output by process start time, so newest are either at the top or bottom ? On Linux ? On SysV5 ? On Mac ?
17
votes
7answers
16k views

Why can't you fsck a mounted partition?

It's well-known that you should never fsck a mounted partition. I can understand how this could easily lead to corruption if the filesystem is written to by fsck (e.g., the -a option is used), but why ...
17
votes
4answers
2k views

What is the first digit for in 4-digit octal Unix file permission notation?

3-digit: 644 ugo (user group other) 4-digit: 0644 ?ugo (??? user group other) What is the first octal digit for in 4-digit octal Unix file permission notation?
17
votes
2answers
12k views

What is the sticky bit in UNIX file systems? When is it used?

What is the sticky bit in a UNIX file system? As an admin when and how would you use it?
17
votes
8answers
6k views

Is there a way to redirect output to a file without buffering on unix/linux?

I have a long running batch process that outputs some debug and process information to stdout. If I just run from a terminal I can keep track of 'where it is' but then the data gets too much and ...
16
votes
3answers
6k views

How i configure monit to start a process with a determinated user?

Monit runs with root, but i don't want to start my processes as root.. like mysql, mongrel, apache..
15
votes
9answers
12k views

Is it feasible to have home folder hosted with NFS?

I'm planning to deploy some kiosk computers and would like to leave them with a small pendrive as boot disk, keeping the rest at an easy to back up server, ala LTSP. Right now I'm pondering two ...
15
votes
5answers
4k views

Bash Loop - How to stop the loop when I press Control-C inside a command?

I am rsyncing a few directories. I have a bash terminal open and am executing something like this: for DIR in * ; do rsync -a $DIR example.com:somewhere/ ; done However if I want to stop the whole ...
15
votes
4answers
13k views

How to pipe stderr without piping stdout

How do I pipe the standard error stream without piping the standard out stream? I know this command works, but it also writes the standard out. Command 2>&1 | tee -a $LOG How do I get ...
15
votes
4answers
1k views

What's the best way to clean up after a fork bomb?

$ ls bash: no more processes Uh oh. Looks like someone made a fork bomb. Where I used to work, this pretty much meant that the shared server would need to be power-cycled, since even the sysadmins ...
14
votes
8answers
3k views

How many and which partitions should I create for a linux server?

Partitions are very important on Linux server because it give you a lot of flexibility, for example when upgrading to a bigger hard drive. But, how many partitions should I create when building a ...
14
votes
6answers
28k views

How do I determine the block size of an ext3 partition on Linux?

How do I determine the block size of an ext3 partition on Linux?
14
votes
4answers
2k views

Can you have more than one ~/.ssh/config file?

We have a bastion server that we use to connect to multiple hosts, and our .ssh/config has grown to over a thousand lines (we have hundreds of hosts that we connect to). This is beginning to get a ...
14
votes
3answers
4k views

To fsck or not fsck after 180 days

By default after 180 days or some number of mounts, most Linux filesystems force a file system check (fsck). Of course this can be turned off using, for example, tune2fs -c 0 -i 0 on ext2 or ext3. On ...
14
votes
3answers
17k views

Getting rsync to move file from source to destination?

Is rsync is a good choice for my project ? I have to : - copy files from source to destination folder via SSH, - be sure all files are copied, - delete source files after copy. - if I have conflict ...
13
votes
3answers
1k views

When should I use “nohup”, and when should I use “&”?

I never know when's the best time to use nohup and the & at the end of the command.