Skip to main content
81 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
  • 356k
81 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
64 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
  • 686
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
  • 148k
50 votes
Accepted

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
  • 9,394
37 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,423
35 votes

tar --list — only the top-level files and folders

The following method works for me to show only the top level files and directory names, tar --exclude='./*/*' -tvf ttt.tar.gz The following method shows one more level, tar --exclude='./*/*/*' -tvf ...
sudodus's user avatar
  • 6,686
34 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
  • 15.1k
34 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
  • 441
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
  • 356k
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
  • 114k
24 votes

Why did my dd command change disk from ExFAT to UDF (Universal Disk Format)

Your dd command replaces the entire contents of the target disk, including its filesystem type and format, with the contents of the source ISO file. The ISO file appears to represent or contain a UDF ...
Chris Davies's user avatar
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
  • 356k
23 votes
Accepted

Why does editing '/etc/shells' file using 'sudo open' shows an error saying I don't own the file?

The macOS command open command will not actually start the editor on its own. Instead, it asks the macOS Launch Services to do it. Your login session's Launch Services component runs as your regular ...
telcoM's user avatar
  • 114k
23 votes
Accepted

File has been changed, but its "date modified" is the same. How is that possible?

You will notice that test.app is a directory: $ tree test.app test.app └── Contents ├── Info.plist ├── MacOS │   └── applet ├── PkgInfo ├── Resources │   ├── Scripts │   │  ...
Kusalananda's user avatar
  • 356k
22 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
  • 356k
22 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
  • 148k
22 votes
Accepted

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
22 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
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.6k
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,423
19 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
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

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
  • 356k
18 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
  • 71.9k
18 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
  • 33.4k
18 votes
Accepted

Why does MacOS always append to a redirected file descriptor even when told to overwrite? Ubuntu only appends when strictly told to append

So, in { printf '%s\n' '1' >/dev/stdout printf '%s\n' '2' >/dev/stdout } > outputfile one might actually expect the redirection > /dev/stdout to do nothing, since what > does, ...
ilkkachu's user avatar
  • 148k
17 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
  • 295
17 votes
Accepted

Why doesn’t `sudo -E` preserve `PERL5LIB`?

Variables matched by the env_delete list are removed from the environment with sudo -E a.k.a. sudo --preserve-env. Passing the variable to --preserve-env= re-adds it with its original value, which ...
Gilles 'SO- stop being evil''s user avatar

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