Skip to main content
76 votes
Accepted

How can I set the default editor as nano on my Mac?

Set the EDITOR and VISUAL environment variables to nano. If you use bash, this is easiest done by editing your ~/.bashrc file and adding the two following lines: export EDITOR=nano export VISUAL="...
Kusalananda's user avatar
  • 337k
69 votes

ssh connection "client_loop: send disconnect: Broken pipe" or "Connection reset by <IP> port 22"

I solved the same problem by editing the file ~/.ssh/config to have: Host * ServerAliveInterval 20 TCPKeepAlive no Motivation: TCPKeepAlive no means "do not send keepalive messages to ...
David Wickstrom's user avatar
63 votes
Accepted

GZip doesn't produce the same compressed result on macOS vs Linux

Note that the compression algorithm (Deflate) in GZip is not strictly bijective. To elaborate: For some data, there's more than one possible compressed output depending on the algorithmic ...
schnaader's user avatar
  • 676
60 votes
Accepted

Why did {} start appearing as äå in Terminal.app?

I can reproduce it with the xterm terminal emulator (version 366), if I do: $ printf '\e[?42h\e(H'; cat chars.txt; printf '\e(B\e[?42l' !É#$%Ü&*()_+äå Where: \e[?42h. Enables National ...
Stéphane Chazelas's user avatar
59 votes
Accepted

Why does awk -F work for most letters, but not for the letter "t"?

Because: Normally, any number of blanks separate fields. In order to set the field separator to a single blank, use the -F option with a value of [ ]. If a field separator of t is specified, awk ...
ilkkachu's user avatar
  • 141k
50 votes

The 01:00 in 1 January 1970 at 01:00

The UK government (in its infinite wisdom) decided to experiment with Daylight Saving Time. It shifted to DST on Sunday, 18 February, 1968, and omitted the shift back that Autumn. It observed DST all ...
Paul_Pedant's user avatar
  • 8,899
35 votes

How to fix "VirtualBox VM quit unexpectedly" when running my Ubuntu 20.04 LTS VM on MacOS Catalina 10.15 in VirtualBox?

Go to Settings > Audio and uncheck "Enable Audio". There seems to be a bug that crashes Ubuntu 20.04 LTS in VirtualBox when it attempts to check audio input permissions with CoreAudio. 00:...
brstream's user avatar
  • 451
32 votes

How do I delete a directory that contains only '.' and '..', but rm says is not empty?

Your directory looks empty, but the ls output indicates that there is a file in there since the link count for the directory is 3 rather than 2 (an empty directory on an APFS filesystem should have a ...
Kusalananda's user avatar
  • 337k
31 votes
Accepted

What is this weird directory in my PATH on my Mac, (running latest macOS Ventura)?

Where is it coming from? Is it safe to keep? Is it okay to remove from PATH? The /System/Cryptexes directories are part of macOS security. Mostly Safari and a few other features use it. So it came ...
James Risner's user avatar
  • 1,302
30 votes

Why do I lose my ZSH history?

ZSH History file can be truncated/lost/cleaned for multiple reasons those can be: Corruption of the zsh history file (because of a power-cut/system-fail while a shell is opened, in this case fsck ...
intika's user avatar
  • 14.6k
29 votes
Accepted

Why does 'ls' only display contents when I'm in a certain directory?

The difference is physical vs. logical treatment of ..: You apparently have two separate Downloads directories: one is /Users/ciprian/Downloads the other is /Users/ciprian/Library/CloudStorage/...
telcoM's user avatar
  • 99.2k
28 votes

Why can't I pipe `pwd` to `open` on macOS?

The open utility on macOS does not read from standard input, but take its arguments from the command line. To open the current working directory, you would have to say $ open "$( pwd )" or $ open "...
Kusalananda's user avatar
  • 337k
23 votes
Accepted

How to move directory into a directory with the same name?

To safely create a temporary directory in the current directory, with a name that is not already taken, you can use mktemp -d like so: tmpdir=$(mktemp -d "$PWD"/tmp.XXXXXXXX) # using ./tmp.XXXXXXXX ...
Kusalananda's user avatar
  • 337k
21 votes

Remove files without string in name

Just invert the name condition in find : find . -type f \! -name "*999*" Add -delete or -exec rm {} + to actually remove the matched files.
ilkkachu's user avatar
  • 141k
21 votes
Accepted

Remove files without string in name

Using an extended globbing pattern in bash: rm ./!(*999*) This requires shopt -s extglob to be enabled (and for safety, also shopt -s failglob, so that no file with the unusual name !(*999*) gets ...
Kusalananda's user avatar
  • 337k
20 votes

GZip doesn't produce the same compressed result on macOS vs Linux

The format should be very stable, but see its description. It contains a field for operating system ID.  Obviously that may differ for macOS and Linux and FreeBSD and ...
vonbrand's user avatar
  • 18.3k
20 votes

How to install docker-engine in macOS without docker desktop?

There is an alternative to docker, it is podman. Install: brew install podman Download and prepare the VM: podman machine init Turn on the VM: podman machine start Uses as a docker: podman run -d -p ...
ruzenhack's user avatar
  • 301
20 votes

What is the convention for options/questions in terminal?

If you just hit enter, it assumes the part in brackets. In your case, the default is “n”.
James Risner's user avatar
  • 1,302
19 votes
Accepted

Why can't I pipe `pwd` to `open` on macOS?

I don't have a Mac so I can't test it, but the solution should be something like: open "`pwd`" Not all programs take their input from stdin which would be necessary for the pipe to work.
Julie Pelletier's user avatar
19 votes

MacOS Terminal start up slow, the window title transitions between "login", "env", "bash" then "zsh" - but /bin/zsh starts fast in isolation

Ok turns out homebrew added around 100 calls to set itself in my ~/.zprofile file
David Alsh's user avatar
18 votes

Replacing string in file with MAC OSX

How it to do with sed in OS X. I've created test file: $ cat test.txt tasdasdasd asd asd as d as d ddddddd ffdfdfdfdfdf Calling sed ('' is necessarily parameter): $ sed -i '' "s/as/replaced_ad/g"...
Yurij Goncharuk's user avatar
16 votes

sed word boundaries, on macOS

sed on macOS uses [[:<:]] in place of \< and [[:>:]] in place of \>. The macOS implementation of sed additionally does not support \b as a word boundary pattern. This is even though the ...
Kusalananda's user avatar
  • 337k
16 votes

No xauth program; cannot forward X11

Both your client and the server are complaining that they can't find the xauth program. The "debug1: No xauth program" message comes from your client, saying it can't find a copy of xauth locally. The ...
Kenster's user avatar
  • 3,440
16 votes
Accepted

mktemp on macOS not honouring $TMPDIR

/var/folders/qg/s5jp5ffx2p1fxv0hy2l_p3hm0000gn/ This is your Darwin user local directory. Its name is simply a modified base 32 encoding of the concatenation your MacOS User UUID and your MacOS (BSD)...
JdeBP's user avatar
  • 69.3k
16 votes

ssh connection "client_loop: send disconnect: Broken pipe" or "Connection reset by <IP> port 22"

David's answer is OK, but a more comprehensive solution is explained below. You can address this problem on either the client or the server. How do you know where to do it? Set it on your machine if ...
Pablo Johnson's user avatar
16 votes

How to install docker-engine in macOS without docker desktop?

On my Macbook, I've installed docker via homebrew with brew install docker docker-compose docker-machine xhyve docker-machine-driver-xhyve (though this was way before docker desktop became non-free, ...
dirkt's user avatar
  • 32.5k
15 votes

Why do I lose my ZSH history?

I don't think any zsh option is going to save your precious .zsh_history. My .zsh_history has been randomly truncated over the years, and I still don't know why. I've tried every option I could find ...
Eric Duminil's user avatar
15 votes

What is the convention for options/questions in terminal?

zsh is not a terminal, it's just a shell, a programming language with an interactive mode specialised in running other commands. Terminal emulators such as xterm, gnome-terminal are configured to run ...
Stéphane Chazelas's user avatar
15 votes
Accepted

Why does `ls` in Linux and macOS show different owners (uid) for the same file?

From the Linux kernel documentation for the hfsplus module: Mount options uid=n, gid=n Specifies the user/group that owns all files on the filesystem that have uninitialized permissions structures. ...
telcoM's user avatar
  • 99.2k
14 votes
Accepted

tr command unable to process colour output piped from grep

To output matches in colour, grep writes colouring escape sequences before and after the match. Those are instructions to the terminals to change their background and/or foreground colour. It's ...
Stéphane Chazelas's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible