A shell is terminology for a command-line interpreter most commonly used with Unix-like operating systems, but also used to interact with GUI-based operating systems in a more granular fashion. Not only does it allows the user to run programs from a text interface, but frequently offers basic ...

learn more… | top users | synonyms

99
votes
3answers
33k 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 ...
55
votes
9answers
47k views

Shell command to monitor changes in a file - What's it called again?

I know there was a command on Unix that I could use to monitor a file and see changes that are getting written to it. This was quite useful especially for checking log files. Do you know what it is ...
53
votes
10answers
15k views

Unique Features of bash compared to zsh

I have been a zsh user for quite some time (before that tcsh and before that csh). I am quite happy with it, but was wondering if there are any compelling features of bash that do not exist in zsh. ...
34
votes
1answer
6k views

What is the difference between a 'Login' and an 'Interactive' bash shell

What is the difference between a ‘Login’ and an ‘Interactive’ bash shell? I have quoted Wikipedia below but can anybody give a better answer? EDIT: This is a community wiki so maybe rather than ...
31
votes
6answers
20k 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 ...
30
votes
2answers
8k views

Colors in bash after piping through less?

When I have dircolors defined life is full of... color. When I pipe ls through less to scroll around I lose the colors. Any suggestions? Thanks, -Mathew
25
votes
5answers
2k views

Linux server out of space

I have been asked this question in two consecutive interviews, but after some research and checking with various systems administrators I haven't received a good answer. I am wondering if somebody can ...
25
votes
4answers
61k views

Adding a directory to $PATH in CentOS?

We just got our new server(s) up and we're running CentOS on them all. After successfully installing Ruby Enterprise Edition, I would now like to add the REE /bin (located at ...
24
votes
3answers
1k views

Did a cat /dev/urandom - Broken terminal

Out of curiosity, when your shell character set breaks from doing something like cat /dev/urandom is there a way to fix that in place?
22
votes
6answers
41k views

How can I kill all stopped jobs?

When I try to exit from my Linux server I get the message: There are stopped jobs. : Is there a single command to kill these?
19
votes
6answers
11k views

How do I join two named pipes into single input stream in linux

Using pipes | feature in linux I can forward chain the standard input to one or several output streams. I can use tee to split the output to seperate sub processes. Is there a command to join two ...
19
votes
3answers
10k views

What is the difference between unlink and rm?

Is unlink any faster than rm?
19
votes
3answers
7k views

How can I check in bash if a shell is running in interactive mode?

How can I tell (in ~/.bashrc) if I'm running in interactive mode, or, say, executing a command over ssh. I want to avoid printing of ANSI escape sequences in .bashrc if it's the latter.
18
votes
23answers
28k 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
2answers
2k views

nologin in /etc/shells is dangerous.. WHY?

I found this on the internet, while putting up a FTP server in FreeBSD. Putting nologin into /etc/shells potentially creates a back door by which those accounts can be used with FTP. (see: ...
17
votes
12answers
10k views

How to pass alias through sudo

I have an alias that passes in some parameters to a tool that I use often. Sometimes I run as myself, sometimes under sudo. Unfortunately, of course, sudo doesn't recognise the alias. Does anyone ...
17
votes
3answers
2k views

What's the difference betwen the single dash and double dash flags on shell commands?

I'm new to working in the shell and the usage of these commands seems arbitrary. Is there a reason one flag has a single dash and another might have a double dash?
17
votes
8answers
5k views

Is there any reason to use bash over zsh?

I'm curious about why one would want to run bash instead of zsh. I mean zsh is fully backwards-compatible with bash. Don't get me wrong: I don't dislike bash or anything. I just genuinely want to ...
17
votes
3answers
718 views

How do I ssh on slow/flaky connections?

I am dealing with a really slow shell connection. It is in the cloud and I am very far from the server. My connection also breaks sometimes as it is over the internet and I may also be using shared ...
16
votes
2answers
3k views

What is /usr/bin/[?

I was just poking around in /usr/bin and I found an ELF binary file called [. /usr/bin/[. I have never heard of this file and my first thought was that it was a clever way of hiding a program, ...
15
votes
5answers
24k views

How to hide the output of a shell application in Linux?

How to hide the screen output (printf) of a shell application in Linux?
15
votes
4answers
11k views

What is “-bash: !”: event not found"

Try executing the following under a bash shell echo "Reboot your instance!" On my installation: root@domU-12-31-39-04-11-83:/usr/local/bin# bash --version GNU bash, version 4.1.5(1)-release ...
15
votes
6answers
11k views

Adding a timestamp to bash script log

I have a constantly running script that I output to a log file: script.sh >> /var/log/logfile I'd like to add a timestamp before each line that is appended to the log. Like: Sat Sep 10 21:33:06 ...
15
votes
2answers
2k views

How can I set environment variable for just one command in fish shell?

In bash, I can do EDITOR=vim crontab -e. Can I get similar effect in Fish shell?
15
votes
2answers
582 views

Bash Prompt Below Output - Background Log Tail

I used to work for a company who had a customised shell for management of one of their products that was running on Linux and I'm looking to replicate a key feature of this shell. All the work was ...
14
votes
9answers
10k views

Live view of Linux shell commands executed by another user?

Is it possible for the root user in Linux to have a real-time (or close to real-time) view of the shell commands being run by another user logged in via a terminal or SSH? Obviously they're stored in ...
14
votes
1answer
10k views

How to interpret output from Linux 'top' command?

Following a discussion made HERE about how PHP-FPM consuming memory, I just found a problem in reading the memory in top command. Here is a screenshot of my top just after restarting PHP-FPM. ...
13
votes
3answers
10k views

Where's my tab completion and up-arrow behavior? (Ubuntu 10.04)

I'm new to Linux, trying Ubuntu 10.04, preconfigured by host. When I log in (SSH) using the preconfigured account, the shell prompt is: user@hostname:~$ The up arrow scrolls through the list of ...
13
votes
4answers
4k views

What is /bin/dash?

I thought /bin/sh was a symlink to my shell of choice. I've always used bash, so I assumed that /bin/sh would point to /bin/bash. It turns out, though, that it points to /bin/dash. It gets funnier. I ...
13
votes
9answers
1k views

Is there a paging version of `watch`?

Under a UNIX shell, how can I get a similar effect to the watch command, but with paging so that I can scroll around in the output if it takes up more than one screen? In other words, I want a ...
12
votes
6answers
34k views

Run a shell script as a different user

What's a good way of running a shell script as a different user. I'm using Debian etch, and I know which user I want to impersonate. If I was doing it manually, I would do: su postgres ...
12
votes
4answers
528 views

How do I start a second shell when in single user mode?

This may sound like a contradiction in terms, but I've recently needed to use single user mode (aka maintenance mode) for some time (days!) while trying rebuild a broken RAID array. While doing this, ...
12
votes
2answers
489 views

backslash at the beginning of a command

In Installing RVM manual I see a lot of lines starting with '\': Install RVM with ruby: $ \curl -L https://get.rvm.io | bash -s stable --ruby I'd think it is just mistype but they repeat ...
12
votes
2answers
8k views

Proxy exceptions when using $http_proxy env var?

In a typical browser, when we set a proxy server, we can define a list of hostnames/IP addresses that are not to use the proxy server. How do we accomplish the same thing when using $http_proxy? I ...
11
votes
4answers
675 views

Is BitTorrent good for copy files between servers in the workplace?

I have 1 source server that contains about 30GB of files that I want to copy to 7 other servers. I currently SCP the files over to the first four servers and when that transfer is complete SCP to the ...
10
votes
7answers
11k views

How to log every linux command to a logserver

I want every single command typed to go to a logserver. Already configured is the syslog-ng to send all logs to the logserver. I'm interested in any and all methods to do this. I would expect ...
10
votes
5answers
1k views

How to remove many (200 000) files?

I must remove 200 000 files (all of them) from a folder, and I don't want to delete the folder itself. using rm, I get an "Argument list too long" error. I've tried to do something with xargs, but ...
10
votes
5answers
280 views

How do I change to the directory I just moved that file to?

So lets assume I've just done: mv ./myfile /to/some/other/place/ And I now decide I want to follow the file, and go into that directory. Whilst I could head for the mouse, select the text, type ...
10
votes
7answers
522 views

Why is this file hidden when you run ls?

EDIT: I totally forgot about this thread. It turns out I had a bad hard disk. We had to redeploy this server for other needs so I finally got around to replacing the one bad disk and we're back in ...
10
votes
2answers
7k views

When to use single-quote, double-quote in grep?

While trying to search for a simple pattern "hello" in a file, all the following forms of grep work: grep hello file1 grep 'hello' file1 grep "hello" file1 Is there a specific case where one of ...
10
votes
3answers
258 views

piping a password and security

I sometimes do echo "secret" | mysql -u root -p .... Now I'm concerend about security here: can someone listing all processes see the password? To check I tried with echo "test" | sleep 1000 and the ...
10
votes
6answers
3k views

What distributed shell utilities do people feel are good, flexible, and easy to use? [closed]

I've been searching and collecting links for a lot of them, but many of these tools don't have enough use case or demonstration documentation to be able to evaluate their potential worth without ...
9
votes
7answers
12k views

Linux: using find to locate files older than <date>

find has good support for finding files the more modified less than X days ago, but how can I use find to locate all files modified after a certain date? I can't find anything in the find man page to ...
9
votes
8answers
1k views

Comparison of Unix shells

Of the major Unix shells (bash, ksh, tcsh, zsh, others?), are there any compelling reasons to use one over another? Which is the most interactive/command-line friendly? Which is the most ...
9
votes
6answers
3k views

what are Powershell's advantages over cygwin/unix-shell

The obvious difference I'm aware of, is the ability to interface to certain MS products, such as Exchange. But for one not having to administer such products, what are the advantages of Powershell? ...
9
votes
6answers
10k views

From a shell script, how can I check whether a MySQL database exists?

mysqladmin -uroot create foo returns an exit status of 1 if foo exists, and 0 otherwise, but of course it will also create the database if it doesn't already exist. Is there some easy way to simply ...
9
votes
3answers
19k views

How to list symbolic link chains?

Given this example: mkdir a ln -s a b ln -s b c ln -s c d If I execute: ls -l d It will show: d -> c Is there a way for ls or any other linux command to show d -> c -> b -> a ...
9
votes
4answers
8k views

run script as user who has nologin shell

All I need to do is to run a specific script as a particual user who does have the nologin/false shell indicated in /etc/passwd. I would run the script as root and this should run as another user. ...
9
votes
2answers
3k views

What is the best way to set an environmet variable in .bashrc?

When setting up a variable in .bashrc should I use export VAR=value or would VAR=value be enough? What is exactly the difference (if there is one)?
9
votes
3answers
13k views

Git shell not enabled?

I'm trying to install git server. When I set default shell for my git user to /usr/bin/git-shell I get an error upon login as git. fatal: Interactive git shell is not enabled. hint: ...