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

learn more… | top users | synonyms

1326
votes
7answers
144k views

How do I make a machine “blank screen” for a period of time (as a penalty) if certain noise levels are reached?

My kids (4 and 5) yell a lot when playing games on the computer. I found an effective cure for this. When I hear loud noises, I ssh into the game computer and do: chvt 3; sleep 15; chvt 7 This ...
439
votes
7answers
278k views

How can I sort the output of 'ls' by last modified date?

How can I sort the output of ls by last modified date?
188
votes
6answers
121k views

How to chmod 755 all directories but no file (recursively)?

How to chmod 755 all directories but no file (recursively) ? Inversely, how to chmod only files (recursively) but no directory ?
174
votes
12answers
27k views

How can I change to the previous directory instead of going up?

I currently spend a lot of my working hours moving back and forth between two paths which are very far down the tree and divert from each other at root. It strikes me that my life would be a lot ...
115
votes
12answers
93k views

How do I detach a process from Terminal, entirely?

I use Tilda (drop-down terminal) on Ubuntu as my "command central" - pretty much the way others might use GNOME Do, Quicksilver or Launchy. However, I'm struggling with how to completely detach a ...
112
votes
7answers
87k views

What does 'source' do?

$ whatis source source: nothing appropriate. $ man source No manual entry for source $ source bash: source: filename argument required source: usage: source filename [arguments] It exists, and it is ...
107
votes
17answers
54k views

How to execute a command whenever a file changes?

I want a quick and simple way to execute a command whenever a file changes. I want something very simple, something I will leave running on a terminal and close it whenever I'm finished working with ...
103
votes
18answers
8k views

What's the quickest way to count the number of each character in a file?

I want to count the A's T's C's G's N's and "-" characters in a file, or every letter if needed, is there a quick Unix command to do this?
91
votes
6answers
33k views

Scroll shell output with mouse in tmux

Mouse scrolling doesn't work in tmux the way it works when I run shell without tmux (in Gnome Terminal). It seems tmux sends mouse scroll events as if I pressed Up/Down keys. But I want it to scroll ...
90
votes
6answers
86k views

chown is not changing symbolic link

I'm trying to change the user/group of a symbolic link with the command: $ chown -h myuser:mygroup mysymbolic/ But it's not changing. I'm logged in as root. The current user/group is set to ...
75
votes
4answers
23k views

What is the difference between shell, console, and terminal?

I'm confused with the terminology. What is the difference between shell, console, and terminal?
72
votes
11answers
45k views

How to reliably keep an SSH tunnel open?

I use an SSH tunnel from work to go around various idotic firewalls (it's ok with my boss :)). The problem is, after a while the ssh connection usually hangs, and the tunnel is broken. If I could at ...
66
votes
2answers
7k views

Is “ps -u” Really a Bad Syntax?

IMHO ps -u shows a very useful output, much better than ps -u $USER: $ ps -u Warning: bad syntax, perhaps a bogus '-'? See /usr/share/doc/procps-3.2.8/FAQ USER PID %CPU %MEM VSZ RSS TTY ...
65
votes
6answers
4k views

How do I perform commands in another folder, without repeating the folder path?

Is there a clever way to do copy and move operations or a command to duplicate a file, without having to do a cd, then mv after, at the same folder? For example, I have to run the following: mv ...
61
votes
2answers
56k views

How do i change my default shell from bash to zsh?

I want to change my shell from the default bash shell to zsh on my Amazon EC2 instances. How do I go about doing it? Thanks!
57
votes
7answers
39k views

How do I make rm not give an error if a file doesn't exist?

I'm writing a makefile that will clean up some useless files at the end of the compilation. If a target has already been made, it will of course skip that target and the useless file may not be ...
50
votes
7answers
45k views

What to do when Ctrl + C can't kill a process?

Ctrl + C doesn't always work to kill the current process (for instance, if that process is busy in certain network operations). In that case, you just see "^C" by your cursor and can't do much else. ...
50
votes
7answers
26k views

Reload a Linux user's group assignments without logging out

When assigning a user's secondary group list using: # usermod -G <grouplist> <user> is it possible to force this group assignment to take effect without logging out all running ...
48
votes
8answers
61k views

sudo with password in one command line?

On busy days, I'd like to run $ ./configure && make && sudo make install && halt on the night and go to bed, hoping the application would automatically be installed. But ...
43
votes
2answers
7k views

Case insensitive tab completion in Bash

Is there any way to make Bash tab complete case insensitively? $ bash --version GNU bash, version 3.2.48(1)-release (x86_64-apple-darwin10.0) Copyright (C) 2007 Free Software Foundation, Inc. I am ...
43
votes
6answers
19k views

How can I make tmux use my default shell?

On a new setup, tmux is using bash instead of my default (zsh). How can I force it to use zsh?
43
votes
3answers
73k views

How to make new file permission inherit from the parent directory?

I have a directory called data. Then I am running a script under the user id 'robot'. robot writes to the data directory and update files inside. The idea is data is open for both me and robot to ...
41
votes
9answers
3k views

Why is Bash everywhere (in most if not all Linux distributions)?

Bash is used by default in every Linux distribution I have tried, over alternatives like Z shell (zsh). Is there a technical or historical reason for this?
40
votes
2answers
4k views

what is the difference between “command && command” and “command ; command”

I see these two usage on Ubuntu "command && command" and "command ; command", e.g. apt-get update && apt-get upgrade What would differ if I use apt-get update; apt-get upgrade? I ...
38
votes
3answers
46k views

What does “2>&1” do in command line?

I know that the > sign is used for output redirection in the command line, but I'm having trouble finding something that explains the use of 2>&1 in the command line. For example: curl ...
37
votes
10answers
2k views

What does an operating system look like without a shell?

A shell like the bash or command.com (up to Windows ME) or CMD.EXE (in later versions) provides an interface that (among other things) accepts commands from the user. What does an operating system ...
37
votes
4answers
10k views

What is the origin of the UNIX $ (dollar) prompt?

The UNIX prompt uses a $ symbol to indicate that your input is expected. I was wondering why this symbol was chosen -- if there is a reason. Dollar just seems a little unexpected. A > would have been ...
36
votes
3answers
49k views

If I know the PID number of a process, how can I get its name?

If I have the PID number for a process (on a UNIX machine), how can I find out the name of its associated process? What do I have to do?
36
votes
9answers
102k views

How do i select all text in Vi/Vim?

I always use vi for editing config files. Today I wanted to select all the text in a file (around 1000 lines), copy it, then paste into Google Docs. How can I do that?
35
votes
2answers
827 views

How do I teach my linux command line manners?

Whenever I complete something in the command line while using Ubuntu and my computer does something of value to me, I enjoy saying thank you, just because it's the polite thing to do. A typical ...
34
votes
3answers
45k views

How can I change shell in Ubuntu? [duplicate]

I have a Ubuntu Server VPS and I want to use /bin/bash/ as my shell. How can I change my shell? I have root access but I don't work as root. So dash is my default shell now. I have read How do I make ...
30
votes
4answers
19k views

Byobu versus gnu screen versus tmux

So far I have used konsole to manage multiple shell sessions but it seems that byobu, gnu screen, and tmux offer a better support for multiple shells. I have never used neither of them before. One of ...
29
votes
5answers
1k views

Deleting millions of files

I had a dir fill up with millions of gif images. Too many for rm command. I have been trying the find command like this: find . -name "*.gif" -print0 | xargs -0 rm Problem is, it bogs down my ...
29
votes
3answers
23k views

Find out if user name exists

How can I find out, in a shell script, whether a given user name exists on the current system? /etc/passwd and /etc/shadow are incomplete. Consider OS X's Directory Services, or Linux with Likewise ...
28
votes
3answers
19k views

Change the Login Shell of Mac OS X Lion from bash to zsh

I trying to change the Login Shell of Mac OS X Lion from bash to zsh. I see it is possible in Mac OS X Leopard (http://hints.macworld.com/article.php?story=20071025221744166) but for OS X Lion I can't ...
28
votes
4answers
2k views

Difference between “a=b” and “export a=b” in bash

What's the difference between: a=b and export a=b In bash? I understand that they both define environment variables, but I don't fully understand the difference.
28
votes
6answers
73k views

looping through `ls` results in bash shell script

Does any one have a template shell script for doing something with ls for a list of directory names and looping through each one and doing something? I'm planning to do ls -1d */ to get the list of ...
28
votes
6answers
28k views

How to find my stolen Macbook

A friend of mine just had her Macbook stolen. Her Dropbox account is still working on the Macbook, so she can see each time the Macbook comes online, and she can get its IP address. She has given ...
27
votes
9answers
4k views

Any shortcut for “cd ..”?

Is there any shortcut for cd ..?
27
votes
5answers
10k views

What is the difference between bash and sh?

I see two types of code being used: #!/usr/bin/sh and: #!/user/bin/bash I searched for this online and opinions vary a lot. The explanations I saw on most websites say that sh is older than ...
27
votes
5answers
2k views

Does running commands verbosely make them slower?

I've found myself using the -v flag for lots of applications less and less (especially for trivial stuff like tar and cp). However, when I did and I was, say, unzipping a large file, it would take ...
26
votes
6answers
7k views

What zsh features do you use? [closed]

I do a lot of work in the terminal so I have learned a lot about my shell of choice, zsh. What features of zsh do you use to make yourself that much more productive at work? One of my favorites is ...
26
votes
4answers
27k views

what does the dot mean at the end of -rw-r--r--. How do you set it with chmod?

I see that some of the files in my directories under Linux have a . at the end of the permissions listing. what does the dot mean at the end of -rw-r--r--. How do you set it with chmod ?
25
votes
7answers
61k views

Copy directory contents using 'cp' command

How do you copy all the contents of one directory into another? For example: $ cd /home/newuser $ cp -a /backup/olduser/* . The problem with the above is that the globing pattern '*' matches the ...
25
votes
2answers
13k views

Bash Shebang for dummies?

I have some bash scripts I have setup that mostly use #!/bin/bash but I regularly come across some that look like #!/bin/bash -e #!/bin/bash -x #!/bin/bash -ex and so on. Can someone explain ...
25
votes
7answers
41k views

List open SSH tunnels

I use a lot of SSH tunnels to various servers on my linux machine (for tunnelling to databases, web servers etc) and it would be really handy to view a list of current open tunnels via a shell script. ...
24
votes
3answers
16k views

What are the differences between fish and zsh? [closed]

I'm a bash user willing to switch to a more friendly and advanced shell. I read a lot of good things about zsh, but I gave a quick test at fish and it seems great too. Both seem very close in term of ...
23
votes
14answers
25k views

Linux command to repeat a string n times

Is there any built-in linux command that allows to output a string that is n times an input string??
22
votes
4answers
27k views

How do I find (and kill) process running on a certain port? [duplicate]

Possible Duplicate: Finding the process that is using a certain port in Linux I'm using Ubuntu Linux 11.04. How do I write a shell script expression that will find the process running on ...
22
votes
3answers
10k views

How to: Unlimited Bash/shell history?

Is there a way to define an unlimited history in Bash ?