A shell is software that lets users interact with the operating system, usually by typing at a command-line.

learn more… | top users | synonyms

14
votes
3answers
18k views

Mac OSX: conventional places where binary files should live

I'm only vaguely familiar with Unix and the filesystem convention for Macs, so sorry if this is a dumb/easy question. I've downloaded an application that is a command-line application, and want to ...
14
votes
6answers
15k views

Stop Windows 7 Explorer from automatically expanding folders

Windows 7 Explorer can be opened in any folder from the command line. But, it automatically expands (on the left nav panel) the Favorites, Desktop, and [Username] folders. This makes it hard to see ...
14
votes
3answers
5k views

How can I do Ctrl-Z and bg in one keypress to make process continue in background?

I follow this pattern of suspending the task and then letting it to continue too often with the Ctrl-Z bg sequence. I was wondering is there any way to compress that to single keypress? My shell is ...
13
votes
5answers
2k views

Finding the definition of a bash function

I work in an environment that has a lot of legacy shell script magic lying around. One thing used heavy from the command line are bash functions that get sourced from some file included from some ...
13
votes
5answers
378 views
13
votes
3answers
4k views

How to set terminal size in Android adb shell?

When I connect to Android using "adb shell" and run certain commands such as "vim" or "mc", they are restricted to a "window" of 25x80 characters. Since I'm connecting from a desktop computer where ...
13
votes
3answers
11k views

What's the difference between /etc/bash.bashrc and ~/.bashrc? Which one should I use?

When should I use each of the two .bashrc files to set my aliases, prompt, etc?
13
votes
3answers
9k views

Check number of pending security updates in Ubuntu

Let me start by saying I have been forbidden to enable automatic updates on our Ubuntu servers, for both security and regular packages. When I log into any of my four Ubuntu servers, the welcome ...
13
votes
7answers
16k views

Change directory using sudo

How to I change into a directory owned by root? If I do: sudo cd RootOwedDir I get: sudo cd: command not found If I su root I get: authentication failure, probably because I never really set up an ...
12
votes
4answers
27k views

How do I rename files with spaces using the Linux shell?

I named a number of files with spaces in them, and I want to replace the space with "_". However, every time I write a command in the shell with the file name (eg "Spring 2011"), the shell doesn't ...
12
votes
7answers
18k views

How can I list only non-empty files using ls?

How can I list (using ls) all files that are not empty (size > 0) using linux?
12
votes
5answers
2k views

Which directory does path `//` represent in Linux?

When I want to go back to upper level directory in Linux by typing cd .., I typo-ed cd //. To my great surprise, no errors are reported. What's more the prompt becomes username@hostname://$. ls ...
12
votes
11answers
18k views

Is there any replacement for putty [closed]

Is there any nice looking terminal with more features and sexy looks than putty? I find it very boring.
12
votes
4answers
13k views

How to diff directories for different files, but not line-by-line

I want to see, recursively, files that are different in two directories. Diff can do this, but it shows me the line-by-line differences, which I don't want. Is there a tool that does this, or a way to ...
12
votes
3answers
56k views

How to display current path in command prompt in linux's sh (not bash)?

I would like to display current path in sh prompt (not bash shell), which currently just shows "#", I tried with introducing this env PS1="$(whoami)@$(hostname):$(pwd)" and set ...
12
votes
1answer
14k views

run or send a command to a tmux pane in a running tmux session

I want to write a shell script which will attach to a named tmux session, select a window (or pane) in that session and run a command in that selected window (or pane). How do I do this from a bash ...
12
votes
4answers
13k views

Linux : To monitor a Service and restart if stopped?

Actually I'm not so sure whether i should use Shell Scripts, or if there some ways already. But whatever approach we use, i would like to keep a Service running all the time. Let's say iptables as an ...
12
votes
3answers
9k views

Bash shell: list all files of type .png or .PNG?

In a bash script, how can I say 'for all files of type .png or .PNG'? I'm trying : for i in (`ls *.PNG` && `ls *.png`) but getting a syntax error.
12
votes
8answers
4k views

Growl Notifications for Shell Task Completion

(OSX Specific) I, like many others besides myself often find myself kicking off a process in the shell that takes a minute or two to complete (a large svn commit for example). During that time, I ...
12
votes
2answers
4k views

How do I host a mintty shell inside of Console2?

I like to use Console2 for my Windows shell work, where I usually make it open a cygwin bash prompt. I'd like to try out MinTTY (2), and want to host it within Console2 as well. If this is possible, ...
12
votes
3answers
4k views

Using wildcards in commands with zsh

Using commands such as rsync and scp with ZSH I've run into trouble. Instead of the (normal) behaviour of giving me all matching files, it won't run and returns: ➜ ~ rsync -azP user@server:~/* ~/ ...
12
votes
2answers
2k views

How can I prevent tmux exiting with Ctrl-d?

I use tmux on my server and recently I found to my cost that ctrl-d will exit tmux and lose all the session information, my intention was to simply end the ssh session but failed to notice I was still ...
12
votes
4answers
9k views

Terminal Vs. Shell [duplicate]

Possible Duplicate: What are the differences between shell , console & terminal? This probably sounds like a stupid question but I'm having a lot of trouble clearly differentiating ...
12
votes
4answers
11k views

Is there a way to edit files inside of a zip file without explicitly extracting them first?

I sometimes need to make changes to a .zip or .jar file, so I usually move the file to /tmp, extract all the files with unzip, edit a few files, and then re-zip up the files. This works, but it can ...
12
votes
3answers
3k views

Making Linux shell prompt show last return value

I'm currently on a Linux machine and the shell prompt is showing me the last return value and number of executed commands (picture included, with these numbers shown in purple). My own computer ...
12
votes
5answers
3k views

How to show the current Vi mode when using Vi keybindings in the shell?

I use the vi keybindings in my tcsh shell. Now, I don't know which vi mode I'm in (insert mode or command mode), which leads to a lot of frustration. Does anyone know of a way to show the current ...
12
votes
4answers
1k views

bash: colorized man page

Where do I have to take a look at in the system to colorize the man pages? The man pages are viewed with less, so I tried adding the following lines to my .bashrc to change the colors: (Which works ...
11
votes
9answers
9k views

How do I copy file named starting with a dot?

I am trying to copy all files under directory A to directory B. All files under directory A are starting with dot, for example: A/.a A/.b A/.c which I found if I use: cp A/* B, always get error: ...
11
votes
10answers
4k views

Determine Linux distribution

I am trying to determine what flavor of linux server is running. I am not trying to determine the kernel version - but rater the distributor. gcc is installed, and in the version output, it says ...
11
votes
8answers
16k views

Windows Vista: How to execute a .exe program in the cmd “As Administrator”

Yes, that's it. I need to run a program .exe in the dos cmd line and it needs to run like when you right button and select "run as an administrator"
11
votes
3answers
1k views

How to run a command in background with no output unless there's an error

How to suppress a command's output but show it if the command exit codes an error?
11
votes
4answers
1k views

Who deals with the star * in echo *

Who deals (interprets) the * in echo * Does the echo see the star or the shell take care about it and return a list of filename .. What about cp temp temp*
11
votes
2answers
8k views

http get from the shell in Mac OS X

I'd like to download a link like: http://example.org/file.mp3 Now, I'm enough of a shell junkie to know what SCP does, but that's about where my geek-dom ends. So is there a shell program that lets ...
11
votes
5answers
16k views

Is there a way to escape single-quotes in the shell?

E. g. I want to say perl -e 'print '"'"'Hello, world!'"'"', "\n";' Is there a less awkward way to do it, e. g. escaping single-quotes? Yes, I know that I can write perl -e 'print q[Hello, ...
11
votes
1answer
2k views

Vim Ignores Aliases

If I map a command in vim using something like map <f4> :! pdflatex %<cr> Vim will ignore my alias for pdflatex (something like alias pdflatex='pdflatex --temp-dir=something'). Is it ...
11
votes
3answers
15k views

TortoiseSVN overlay icons do not appear when installed by a different user account?

I've installed TortoiseSVN on my work Windows XP machine as the administrator. When I login in as a standard user my working copies do not display the overlay icons in Windows Explorer. I found this ...
11
votes
2answers
13k views

How to calculate a relative path from two absolute paths in Linux shell?

We have two paths. First one is directory, second either dir or file. /a/b/c and /a/d/e.txt Relative path from first path to second will be: ../../d/e.txt How to calculate that in Linux terminal? ...
11
votes
3answers
3k views

How can I launch a file properties dialog from the command line?

It's simple programmatically with ShellExecute to specify the properties verb when instructing Windows to open a file, but can this be done from the command line or run box? Ideally I'd like to do ...
10
votes
2answers
1k views

How to cut a file to a given size under Linux?

I want to shrink a file's size by brute-force, that is, I don't care about the rest, I just want to cut the file, say by half, and discard the rest. The first thing that comes to mind is Perl's ...
10
votes
6answers
7k views

What's the difference between the terms “Shell” and “Bash”?

What is the the difference between "Shell" and "Bash" and what do these terms mean? As far as I know, there is no difference. But I've seen many books about "Shell" and others about "Bash"! So in ...
10
votes
6answers
6k views

Best practices to alias the rm command and make it safer

Some time ago I erroneously deleted my home folder because I ran a rm -rf * on the wrong terminal, whose working directory was the home folder! I wish I had an alias for the rm command, but it was ...
10
votes
5answers
549 views

What's the difference between filename and ./filename in Linux

What is the difference between filename and ./filename? Under what circumstances is one preferred to the other?
10
votes
8answers
3k views

Mass renaming, *nix version

I was looking for a way to rename a huge number of similarly-named files, much like this one (a Windows-related question) except that I'm using *nix (Ubuntu and FreeBSD, separately). Just to sum up, ...
10
votes
5answers
12k views

How can I sort all files by size in a directory?

How can I display the files in a unix directory sorted by their human readable size, going from largest to smallest? I tried du -h | sort -V -k 1 but it does not seem to work.
10
votes
4answers
627 views

Is it possible to print out the shell expansion?

I know there is a specific set of rules that shell expand the commands user typed. (let's talk about bash shell.) Is it possible to print out a command in the form after shell expansion? It seems to ...
10
votes
4answers
18k views

echo newline character not working in bash

I have bash script which has lots of echo statements and also I aliased echo to echo -e both in .bash_profile and .bashrc, so that new lines are printed properly for a statement like echo ...
10
votes
4answers
7k views

Better way to do “echo $x | sed …” and “echo $x | grep …”

I often find this in scripts (and, I have to admit, write it myself): a=`echo $x | sed "s/foo/bar/"` or if echo $x | grep foo then ... fi Consider "foo" to include some regex stuff. I feel ...
10
votes
2answers
9k views

How can I found out if file is alias or symbolic link?

I'm working on a legacy system and I have a bunch of files that are referencing images that are located in other folders. lrwxrwxrwx 1 user nobody 56 Feb 10 2010 t100x100.jpg -> ...
10
votes
4answers
11k views

Linux command to return number of bits (32 or 64)?

What is a Linux command that I can run to programmatically return either 32 or 64 to indicate whether the processor is a 32 bit or 64 bit processor?
10
votes
5answers
7k views

gzip all files without deleting them

I need to gzip all files in a dir separately including all files in sub-directories without deleting the originals afterwards. So let's say I have index.html, I want to have at the end index.html.gzip ...