Questions tagged [command-line]

Using programs and commands that do not have a graphical user interface (GUI) but are rather controlled by typing text commands into a terminal program, or shell.

Filter by
Sorted by
Tagged with
1 vote
1 answer
47 views

How to launch docker container from CLI in MacOS (eg `docker run ...`)?

How can I launch a docker container from the command-line in MacOS? In Debian Linux, I can execute the following commands to install docker, launch a new docker container based on the latest version ...
0 votes
1 answer
9 views

wget - How to create local subdirectories when using ‘-P prefix’ ‘--directory-prefix=prefix’?

I have added --directory-prefix=~/Downloads in ~/.wgetrc Looking through the manual for wget I am having trouble understanding how to pass a local subdirectory on the command line that would amend the ...
1 vote
1 answer
689 views

Usage: tmutil listlocalsnapshots <mount_point>

my Mac's system has 184GB. I believe that's for time machine's local snap shot. I tried to tmutil list localsnapshots, but Usage: tmutil listlocalsnapshots <mount_point> returned. I’m not clear ...
1 vote
1 answer
34 views

How can the availability of SetFile and GetFileInfo be detected without causing user interaction? Where are Commandline Developer Tools installed?

In bash, to detect whether a command COMMAND is available, the following statement shall be executed. (Note that I configured bash to be the default shell, instead of zsh.) type COMMAND... For ...
0 votes
0 answers
20 views

Cannot run shell script from mounted network share: unidentified developer

We have a few shared shell scripts on our file server, and would like them to run in Terminal when double-clicked in the Finder. The share is mounted, and the scripts do run when called by their full ...
2 votes
4 answers
1k views

Edit contents of file from Finder with text editor

As a developer I need to constantly be examining/editing the contents of text files, and opening them from Finder and the command line. I would like to right click the file in finder, and have the ...
23 votes
4 answers
17k views

Change file association in terminal?

Is there a method for associating file types with applications via terminal? I thought ~/Library/Preferences/com.apple.launchservices.plist might do it, and I also have seen: Why is a command line ...
0 votes
1 answer
550 views

How to display the full command history in terminal?

Since updating to Big Sur, the history command (terminal) shows only the last 16 commands. Do you have any ideas how to get the full history back?
8 votes
2 answers
918 views

Using pbcopy & pbpaste with rich text formatting results in empty clipboard

I've found plenty of resources that say this should work, but I'm having no luck with rich text formatting with the pcopy & pbpaste commands on MacOS Catalina 10.15.4. % echo '**foo**' | pandoc -...
-1 votes
0 answers
27 views

Can't find etc/hosts on my my level

So I'm troubleshooting my Mac right now to try and find out what is happening and why I can't connect. First place I go to check is my etc/hosts/ and I pull it up on Terminal and find its empty. I use ...
3 votes
1 answer
543 views

Removing old versions of XCode Command-Line Tools on macOS 12

I recently got a new M1 MacBook which I migrated to using Migration Assistant. As part of the migration, the old XCode command-line tools seem to have made their way over, install receipts and all; ...
0 votes
1 answer
56 views

Cannot `ls` or `cd` on external drive

I have an external drive. When I cd /Volume/My Book Thunderbolt Duo and try to do ls, I get an "operation not permitted" error. The drive shows in Finder just fine.
0 votes
3 answers
56 views

zsh/bash string to array not working using parentheses

Do you know why the following is not converting string into array? STR="one two three" array=("$STR") echo "${array[@]}" # prints: one two three echo "len: $...
0 votes
0 answers
32 views

How do I force install updates that `softwareupdate -l` doesn't show (but should)?

(16in 2019 Intel MBP, 12.3.1) So I'm trying to apply software updates that should get me from 12.3.1 to 12.5, and am well past the stage of trying to get the system Software Update tool to apply them. ...
6 votes
3 answers
8k views

Command to find out the version number of a .pkg file

Does anyone know how to retrieve the version number of a .pkg file which isn't installed yet? I'd like to use something like pkgutil --pkg-info, but that only works for installed packages. I've ...
0 votes
1 answer
82 views

Getting extra character when copy string to iTerm

I'm using iTerm and when when pasting some string I've just copied from the terminal command prompt, I get some extra characters on prefix and suffix that match 00~ and 01~ respectively. I.e. I've ...
0 votes
1 answer
53 views

`sudo passwd` asking for old password / reset recovery key

I'm an admin on my Mac (macOS Montrey 12.5), but forgot my own password. I can login remotely from another machine (SSH key based auth), and I have sudo configured with NOPASSWD for the admin group. ...
40 votes
6 answers
98k views

sudo killall coreaudiod made it so I don't have any sound at all

I ran into an issue where my volume buttons on my mac weren't able to adjust the volume of my computer. I sought a solution and someone suggested using sudo killall coreaudiod. Now I have no volume on ...
0 votes
1 answer
24 views

Load SMB path in finder via command line

I have an SMB path that I need to browse to in the finder. I used to do this all the time with the following: open smb://path/to/directory I just updated to Big Sur and now every time I do this, I ...
15 votes
7 answers
17k views

Monitor a folder for changes, and run a command when a change is detected

Is there a simple way to automatically run a (Terminal) command every time a file is changed in a specific folder? This should be possible via the command line, or a system built-in application, no ...
3 votes
2 answers
2k views

How to add a new locale to macOS Catalina

On System Preferences, Language and Region, when I select United Kingdom the output of locale is LANG="en_GB" LC_COLLATE="en_GB" LC_CTYPE="en_GB" LC_MESSAGES="en_GB" LC_MONETARY="en_GB" LC_NUMERIC="...
0 votes
2 answers
23 views

Using terminal (ie, zsh), I want to run a certain shell command, every time, any file in a given folder is saved/added [duplicate]

Hence, in a certain folder, say ~/Desktop/foo, any time a file/subfile/folder is touched (added, saved), I want to just run a certain command in the shell. Is there a way to do this, either with a zsh ...
4 votes
1 answer
807 views

how dangerous is it to give zsh full disk access?

I have a shell script that runs a few (Duplicacy) backup commands. It works fine when I manually run the script from terminal (cd to the directory where it is and then ./backup.sh). To make it run ...
4 votes
0 answers
99 views

Unable to SSH to other servers after Monterey 12.5 upgrade [duplicate]

For some reason ssh connections from my computer to other devices do not seem to work after OSx upgrade, have already restarted it, shut down, started it back up. Do not see anything being blocked ...
3 votes
1 answer
75 views

As of macOS Big Sur, how do you see generator used by Quick Look?

Before macOS Big Sur, qlmanage -p by itself or qlmanage -p -d debugLevel showed which Quick Look generator was used for a given file. Now, no such info appears. The man page for qlmanage also changed ...
6 votes
2 answers
10k views

ss (netstat alternative) for OS X

How do I install ss on OS X? I couldn't find the iproute package in homebrew. Red Hat recommends ss over netstat in Red Hat Enterprise Linux 7. ss is provided by the iproute package. Red Hat ...
0 votes
1 answer
41 views

After upgrade to Monterey, a user-created launchd job does not run

I have a launchd job that is supposed to run a php script at 6am every day. The script runs a number of backup-related tasks. After upgrading to Monterey, the task no longer starts at its scheduled ...
2 votes
0 answers
38 views

In Terminal, how do I access the hyperlink in hyperlinked text stored in the clipboard?

If I copy some text containing a hyperlink and then paste into another application that accepts it, then the text and its hyperlink is correctly copied over. How can I access this hyperlink via the ...
1 vote
1 answer
121 views

How to use different SOCKS proxy for different CLI apps?

based on some politics I cannot use proxychains* utilites ( no preload accepted ). As I understood is no chance to achieve it using sandboxes and no netspaces yet in OSX. I can play with the firewall ...
2 votes
1 answer
682 views

Fixing macOS Big Sur Finder SIDEBAR width prefs from command line?

My default sidebar width in Big Sur is too small. While I can click/drag to make folders look wider, that fix only works for folders that I open. If any application calls a new window to open - say ...
0 votes
0 answers
18 views

How to build .xcodeproj files with the Command Line Tools Package when xcodebuild doesn't work?

For the purposes of automated testing, I'm looking to build an XCode project file from the command line on a headless Mac (which I believe is running Monterey). The machine I'm hoping to build things ...
0 votes
0 answers
22 views

How do I get rid of superfluous outdated software updates?

I have updated to macOS Monterey 12.5 and Xcode 13.4.1 and installed the CLI tools for Xcode 13.4.1. But Software Update keeps telling me to update the command line tools for 13.2 13.3 and 13.4: % ...
32 votes
5 answers
28k views

My Automator Workflow fails because it fails to find the git command within the 'Run Shell Script' command? Need help

I have an Automator workflow and one of the actions is to clone a repository. Here's the code for the 'Run Shell Script' action. The command is run within the Bash shell /bin/bash if that matters: ...
0 votes
3 answers
75 views

List folders with size and number of files

I'm trying to clean up my files and I'm struggling with some command line stuff. With the command du -sh * I can get a nice list of all folders where I use the command. How can I also get the number ...
2 votes
3 answers
724 views

crontab doesn't seem to recognize `~`

Has anybody noticed that crontab doesnt seem to recognize ~ to mean the home directory? I tried using a full expansion of /Users/username/filename.txt in crontab, which worked, but using ~/filename....
2 votes
2 answers
65 views

Send email from command line (macOS Monterey 12.3)

I'm trying to send an email from the command line but it does not work: echo "Hello World" | mail -s "Test email" someone@example.com Years ago "it just worked" because ...
8 votes
1 answer
1k views

MacOS Monterey Terminal CLI: "open" command does not change focus

Has anyone encountered an issue in which Terminal.app is no longer able to switch focus to another application? For example, typing in the command open . would have previously opened the current ...
0 votes
0 answers
24 views

Mu fails to install and Mu4e fails to start: /usr/local/opt/emacs not present or broken

I upgraded mu and emacs and now mu4e stopped working. I removed Emacs with: brew uninstall --force emacs brew uninstall --force homebrew/cask/emacs and mu with: brew uninstall mu Then I installed ...
0 votes
0 answers
13 views

Is there a way to detect if Universal Control is currently connected?

I have a machine that is sometimes connected to one secondary Mac using Universal Control, and sometimes another. I've been doing some automation around Lock/Screensaver events (using EventScripts), ...
4 votes
1 answer
8k views

How can I get the CPU temperature from the command line on Apple Silicon M1

I wanted to monitor handy temperature data like I did dozen times on Linux machines. No problem! I found a beautiful one-liner: sudo powermetrics --samplers smc | grep -i "CPU die temperature&...
75 votes
3 answers
126k views

How can I display the current DNS servers from the command line under OS X?

I want to display the DNS servers that are used by the current network setup on OS X, from the command line.
1 vote
2 answers
1k views

Setting Safari preferences from script on Big Sur

I have a Mac mini 2020 with an M1 processor and running macOS Big Sur. On older macs I had this script to set Safari preferences # Show status bar defaults write com.apple.Safari ShowStatusBar -bool ...
5 votes
1 answer
70 views

Is it possible to limit resource usage by user in macOS?

We have a mac1.metal instance in AWS. Configured with 2 users, one for the QA team and another one for Devs. I'm trying to limit the resource usage of the users, so the any of the teams can't claim ...
0 votes
1 answer
34 views

When i press "CTRL + C" at "caffeinate -i" I get a non 0 exit status. Why?

If I press CTRL + C at caffeinate -i I have a non 0 exit status. My terminal prompt shows me with red x that the previous command had a not 0 exist status. Why is that?
7 votes
2 answers
144 views

Terminal Displays My Roommate's Computer

I don't know how long ago this happened, but today I realized that when I open up terminal it no longer says Matthew-MacBook:~matthew$ as it used to. Instead, it appears to have synched up with my ...
1 vote
1 answer
180 views

Terminal "history" command brings back different results

In OSX's terminal, I run the history command to find my recent commands. Often I notice recent commands will not show up, seemingly randomly. For example, I will log on one-day and notice my commands ...
0 votes
0 answers
28 views

Can macOS adjust gamma from the command line in terminal.app?

I searched and could not find any easy way to adjust gamma without going through a bunch of preference pages. I just want to be able to adjust gamma easily through terminal if possible. I know there ...
5 votes
3 answers
5k views

Tar excluding ._ files

Is there a way to create a tar file in OS X (Sierra, preferably) that does not include the ._ files? I've tried using the --exclude option, but clearly don't know the right pattern to use.
18 votes
3 answers
26k views

How to remove xattr com.apple.quarantine from all .webarchive files with that extended attribute?

Spread across multiple file system I have numerous .webarchive files that were saved by OmniWeb. So for example: sh-3.2$ ls -@ 2012-03-19.webarchive 2012-03-19.webarchive sh-3.2$ ls -@l 2012-03-19....
3 votes
1 answer
203 views

How do I get mdfind to look in /opt?

mdfind does not seem to find files in /opt. e.g. $ mdfind -onlyin /opt -name Dockerfile $ find produces the expected result $ find /opt -name Dockerfile /opt/homebrew/Dockerfile /opt/homebrew/Cellar/...

1
2 3 4 5
56