Questions tagged [shell]

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

Filter by
Sorted by
Tagged with
43 votes
3 answers
19k 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 ...
Cas's user avatar
  • 1,808
43 votes
4 answers
33k 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 the ...
coneybeare's user avatar
43 votes
2 answers
9k views

Why does ‘tmux’ create new windows as login shells by default?

When you start a new session in tmux or create a new window inside a running session, its default behavior is to run a shell (ex.: bash) as a "login shell". I understand that a login shell ...
leogama's user avatar
  • 583
42 votes
5 answers
228k views

How to test if a variable is equal to a number in shell

I have this shell script that isn't working. Input: Server_Name=1 if [ $Server_Name=1 ]; then echo Server Name is 1 else echo Server Name is not 1 fi Output: Server Name is 1 But, if i ...
user2649805's user avatar
42 votes
9 answers
85k views

Linux Shell: Copy output into clipboard w/o using the Mouse?

Is it possible to copy the output into the clipboard without using the mouse? For example, I would like to do something like this: $ pwd >> clipboard
Hayek's user avatar
  • 1,985
41 votes
5 answers
5k views

Can ',,' be aliased to '..'?

Sometimes when I want to change to the parent directory, I mistakenly type cd ,, instead of cd ... Is there a way I can make bash consider these statements to be the same? I never use commas in my ...
kilojoules's user avatar
40 votes
2 answers
17k views

Putty SSH: CTRL+Cursor keys don't work skip to previous/next word

When I am connected to my local Ubuntu dev server with putty (from my Windows 7 box) via SSH, the following key combinations don't work to move the cursor forward and backward on word boundaries: ...
user26767's user avatar
  • 611
40 votes
8 answers
64k views

Why can't I highlight text in a linux terminal emulator with shift+arrow keys?

These are the standard text editing keyboard shortcuts that I use constantly whenever editing text in, literally, any linux application other than terminal emulators: ←+→ arrows to move left+right ...
monguin's user avatar
  • 591
39 votes
6 answers
114k 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 ...
Phil Braun's user avatar
38 votes
5 answers
13k 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 ...
Corepuncher's user avatar
38 votes
3 answers
57k views

How do I fork a process that doesn't die when shell exits?

If I run emacs from the shell: $ emacs foo & and then kill that shell, emacs dies. How can I run a command so that it will not die when the shell dies? I found references to nohup, but that ...
sligocki's user avatar
  • 878
38 votes
5 answers
10k 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 ...
nopcorn's user avatar
  • 16.7k
37 votes
4 answers
28k views

How do I change a users default shell in OSX?

What is the correct OSX way of changing a users default shell? When I googled for it I found several references to an application called NetInfo Manager but I couldn't find it on my system. There were ...
David Holm's user avatar
37 votes
3 answers
40k views

How to remove shell integration of Notepad++?

I want to remove Notepad++'s annoying shell integration when right-clicking a file in Windows. How do I do that?
Grumpy ol' Bear's user avatar
37 votes
3 answers
157k views

how to set ENV variable in windows CMD line

I'd like to set a temporary enviroment variable in windows CMD line, which in my word the windows shell. because it's for temporary usage, So I don't want to add a new enviroment variable system wise ...
HaiYuan Zhang's user avatar
37 votes
11 answers
37k 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: cp:...
user59285's user avatar
  • 505
37 votes
6 answers
123k views

Windows & Git Bash: Bash PATH to read Windows %PATH% system variable

I've recently added a directory to the Windows PATH manually by going into Control Panel -> System -> Advanced system settings -> Environment Variables -> User variables -> PATH. (...
Ahmed Fasih's user avatar
36 votes
5 answers
53k 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 ...
xpt's user avatar
  • 8,681
36 votes
5 answers
31k views

How to change the default shell in Cygwin?

I am trying to change my default shell from bash to zsh in cygwin. The normal unix command chsh isn't available on cygwin The etc/passwd file it seems isn't used anymore in existing versions of ...
gyaani_guy's user avatar
36 votes
2 answers
73k views

how to bring a background job to foreground

in Linux/shell, how can I bring background jobs to foreground and vice versa?
user23993's user avatar
  • 461
36 votes
7 answers
41k 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 ...
SRobertJames's user avatar
36 votes
5 answers
25k views

Bash/ZSH: Undoing 'disown'

Is there a way to 'reattach' a process to the shells job table after it it has been 'disowned'? Edit: $SEARCHENGINE totally fails me. Doesn't look too good.
nisc's user avatar
  • 1,112
36 votes
2 answers
33k views

Shell SIGKILL Keybinding

How can I setup a keybinding to send a SIGKILL to the current foreground job? I already know that Ctrl+C is SIGINT and Ctrl+\ is SIGQUIT. I would like a more severe option. Is there anything ...
drewrobb's user avatar
  • 881
35 votes
7 answers
37k views

zsh with Cygwin

How can I configure zsh to be the default shell under Cygwin?
simao's user avatar
  • 903
35 votes
4 answers
89k views

How to change proxy setting using Command line in Mac OS?

I am using Mac OS and sometimes some work need to be done using a proxy so I need to change my proxy setting frequently. But changing proxy setting in System Preferences is very messy. Is there a ...
flanker's user avatar
  • 353
35 votes
2 answers
1k 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 ...
Sam Becker's user avatar
  • 2,182
34 votes
6 answers
12k 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 ...
Frew Schmidt's user avatar
  • 1,261
34 votes
4 answers
36k views

Why is the size of a directory always 4096 bytes in unix?

I am sure a directory file has much less information than 4096 bytes. I know the sector size is 4096 bytes. But normal files smaller than that do exist. Why does Unix reserve 4096 bytes for each ...
Lazer's user avatar
  • 17.7k
33 votes
4 answers
13k views

ZSH tab completion of git commands is very slow. How can I turn it off?

If I type: rm <TAB> I'll see possible completions almost instantly. However, if I type: git rm <TAB> It'll hang for several seconds if it's in a git repo, or fail to show any ...
Casey Rodarmor's user avatar
33 votes
7 answers
29k views

How to "undo" unzip command?

I used "unzip XXX.zip" to extract a zip file, unfortunaly, i make a mistake. Now i want to delete all the file and directorys generated by "unzip". How can I undo it?
hero2008's user avatar
  • 637
33 votes
2 answers
155k views

Shell script echo new line to file

I want to echo a new line to a file in between variables in a shell script. Here's my code: var1="Hello" var2="World!" logwrite="$var1 [Here's where I want to insert a new line] $var2 echo "$logwrite"...
daviesgeek's user avatar
  • 1,639
33 votes
2 answers
148k views

HOSTNAME environment variable on Linux

On my Linux box (Gentoo Linux 2.6.31 to be specific) I have noticed that the HOSTNAME environment variable is available in my shell, but not in scripts. For example, $ echo $HOSTNAME returns ...
user avatar
33 votes
2 answers
125k views

What is the right way to set the $PATH variable in .zshrc

When I first installed Zsh (using Oh My Zsh), the ~/.zshrc file had the following commented lines by default: # If you come from bash you might have to change your $PATH. # export PATH=$HOME/bin:/usr/...
ARK's user avatar
  • 450
32 votes
5 answers
26k views

Aliases in subshell / child process

I set up aliases in /etc/profile.d/alias.sh for each login shell. But if I run script.sh, I can't use that alias. How can I set alias even for subshells or child processes ? /etc/profile.d/alias.sh ...
lisak's user avatar
  • 455
32 votes
4 answers
10k views

What does % do in Linux shell strings?

In Linux shell, what does % do, as in: for file in *.png.jpg; do mv "$file" "${file%.png.jpg}.jpg" done
Nissim Nanach's user avatar
32 votes
2 answers
49k views

How do i configure a Logitech G502 Spectrum under Linux?

I'm thinking about buying a Logitech G502 Spectrum (the G502 with RGB LEDs) but as I am running Linux (Speciified in Debian @ work, ubuntu @work and archlinux @home) I am woundering how to setup ...
0x1ad1b88's user avatar
  • 486
31 votes
4 answers
76k 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 port ...
user avatar
31 votes
11 answers
171k views

Running scripts from another directory

Quite often, the script I want to execute is not located in my current working directory and I don't really want to leave it. Is it a good practice to run scripts (BASH, Perl etc.) from another ...
Desmond Hume's user avatar
  • 2,600
31 votes
4 answers
11k views

BASH history truncated to 500 lines on each login

For some reason, I cannot get my system to keep my BASH history after a reboot. Here are the relevant sections of my ~/.bashrc: shopt -s histappend PROMPT_COMMAND='history -a; updateWindowTitle' ...
terdon's user avatar
  • 53.4k
31 votes
5 answers
22k 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 ...
Ev Dolzhenko's user avatar
31 votes
8 answers
120k views

How do I run the Windows 7 Explorer shell with Administrator Privileges by default?

The Windows 7 shell (Explorer) can be made to run with Administrator privileges by this manual process: Kill Explorer shell by holding down Shift+Ctrl, right-clicking the Shut down button in the ...
Barry Kelly's user avatar
30 votes
9 answers
8k views

Any shortcut for "cd .."?

Is there any shortcut for cd ..?
tirenweb's user avatar
  • 1,349
30 votes
8 answers
9k views

Is it possible to restart a computer in response to an email notification?

I'm looking for a way to reboot machines after getting an email notification. The setup I want to use this on is a render farm. We have 5 boxes with 8 Nvidia GTX 980Ti in them. They're running ...
Ryan's user avatar
  • 941
30 votes
6 answers
98k views

Why run a Linux shell command with '&'?

I am using Red Hat Linux Enterprise version 5. I've noticed people sometimes running commands with a couple of & options. For example, in the below command, there are two & signs. What is the ...
George2's user avatar
  • 5,049
30 votes
9 answers
25k views

loading local shell aliases to ssh session dynamicaly

When I log in to some machine using ssh I wish my aliases and functions are there. In other words, log in to some machine I wish I can use my command shortcuts. I need it be dynamic, every time I'm ...
Tomek Wyderka's user avatar
30 votes
3 answers
73k views

How to run pip in non-interactive mode?

Most of tools I'm using have some mode (often ON by default) where they ask me zero questions while running the command. apt-get is an example close to pip. There's -y option which makes it non-...
vladimir's user avatar
  • 497
30 votes
3 answers
40k views

What is the difference between CMD and Command prompt in windows?

Until now, I never thought (and never observed) that cmd and command are two different things. Well, are they? Take a look at this pic: Actually, I usually open cmd from the Run dialog whenever I ...
Surya's user avatar
  • 433
30 votes
1 answer
23k views

ZSH Completion colors and OS X

Consider this minimal .zshrc : export CLICOLOR=1; export LSCOLORS=exfxcxdxbxegedabagacad; # It is the default value on OSX, so this line can be omitted autoload -Uz compinit compinit zstyle ':...
user avatar
29 votes
3 answers
23k views

How do I make "find" exclude the folder it searches in?

I'm running the following command: find /var/www/html/content/processing -type d -mtime +1 -exec rm -rf {} \; I would like to delete all the folders under the processing folder (the processing ...
Elad Dotan's user avatar
29 votes
3 answers
23k views

Setting pipefail for a single piped command

I need to execute a number of piped shell commands from a non-BASH script (namely PHP script) like these: command1 | command2 | command3 so that, if command1 fails with a non-zero exit code, each ...
Desmond Hume's user avatar
  • 2,600

1 2
3
4 5
82