New answers tagged

2

Placing alias commands in your bash profile will gain you partial overwrite protection. As others mentioned in your comments, you will need to write a script add the diff function. I placed the commands below in my ~/.bash_profile. Bash on macOS determines what file is your bash profile in this order: ~/.bash_profile ~/.bash_login ~/.profile These ...


1

The system default $PATH variable is set in the file /etc/paths. That file has a one directory per line structure. There are also multiple others files that can set or modify the path variable - user specific configuration files, and shell specific ones, that only apply if you use that specific shell. I suggest not editing the system default file (/etc/...


1

Sending mail from the command line involves two things. Open the Apple mail app (/Applications/Mail.app only) and make sure your default account can send mail (or be sure you configured internet accounts preference pane to provide Apple mail credentials for sendmail ) Send the mail without making any command line or Unix changes. How to send an email from ...


2

The easy way to find the plist key for a given preference is to open a Finder window of ~/Library/Preferences, set it to List View, sorted by Date Modified. Then, set the preference and see what file gets modified. From that, I get two almost identical files modified (on 10.14.5): com.apple.driver.AppleBluetoothMultitouch.trackpad.plist com.apple....


1

Thanks to fd0, I was able to resolve the problem. The output $ type -a du du is aliased to 'du -sh' du is /usr/bin/du makes clear that the command du was aliased to du -sh. By removing this line from my .bash_profile, everything works as it should. The solution e.g. by PeterVP works perfectly fine: $ du -h -d 1


1

This is actually not straightforward to do, but other people have run into this and written codes you could use. See here.


2

Similar question on StackOverflow If you're programmatically doing this, one way to get the opened app's pid (subsequently using it to kill the process) is to get the grep the output of ps aux passing it the application's name. ps aux | grep -v grep | grep -I <AppName> | sort -rn | head -1 | awk '{print $2}' Basically, pipe the output of the ps ...


2

du -h -d 1 seems to work on my Mac


1

Type the following-> sudo -s Enter your admin password. The prompt should now end in #. Enter-> chsh -s /bin/sh root and exit the "root" shell and test.


1

Going off of @TheMadsen's answer above, you can setup a bash script like so: #!/bin/bash while true; do top -l 1 -s 0 | grep PhysMem | awk 'BEGIN {S["G"]=1024; S["M"]=1} /PhysMem:/ {U=substr($2, 1, length($2)-1) * S[substr($2, length($2))]; N=substr($6, 1, length($6)-1) * S[substr($6, length($6))]; printf("%.2fG / ...


2

A bit verbose, but the following awk snippet does this $ echo 'PhysMem: 5490M used (2569M wired), 11G unused.' \ | awk 'BEGIN {S["G"]=1024; S["M"]=1} /PhysMem:/ {U=substr($2, 1, length($2)-1) * S[substr($2, length($2))]; N=substr($6, 1, length($6)-1) * S[substr($6, length($6))]; printf("%.2fG / %.2fG\n", ...


1

I hooked up tcpdump to see if the sender side is in fact sending datagrams: $ sudo tcpdump -i lo0 udp port 5555 tcpdump: verbose output suppressed, use -v or -vv for full protocol decode listening on lo0, link-type NULL (BSD loopback), capture size 262144 bytes 13:53:29.964728 IP6 localhost.49781 > localhost.personal-agent: UDP, length 6 Datagrams are ...


0

Apple looks to have fixed it. I had submitted a bug report, but I'm not sure if that helped or not.


0

I can't because a .CDA (CD Audio) file is a Windows file, created as a shortcut to a file located on a CD. The file doesn't contain any Audio data. I had to rip the CD on my Windows machine, then copy the ripped (located in the Music folder) files onto my Mac.


1

Typical users shouldn't do this, but you're not typical are you? Two issues: You can't stop root. If you insist on using root, then root can overwrite brew.sh no matter what. You can't stop brew, after all, you're talking about running brew. So we'll work with that. Let's setup an alias to copy over brew.sh then run brew. alias brew='cp /<modified>/...


2

Choose one of the following: Surround the part of the path containing spaces in quotes: ln -s /Volumes/"HARDDRV BKUP"/iphonebkup/Backup/ ~/Library/Application\ Support/MobileSync ^ ^ Surround the entire path in quotes: ln -s "/Volumes/HARDDRV BKUP/iphonebkup/Backup/" ~/Library/Application\ Support/MobileSync ^ ...


-1

As of being stupid, I found an answer. brew install wine It's t h a t simple. Before typing the command above, /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" I might delete the comment above.


2

Here's an alternate method. Lines are not added or deleted from the sudoers file. The line giving admin root rights is commented out and we create a separate file with mac_admin's rights in the directory /etc/sudoers.d. And as a bonus, the original sudoers file is backed up. printf '%s\n' 'mac_admin ALL=(ALL:ALL) ALL' > /tmp/99-macadmin visudo -c -f /...


1

Amazing! It worked! Thank you very much! @nohillside I'll add a line above that to add a user mac_admin before the script executes so the final version should look like this. echo 'mac_admin ALL=(ALL:ALL) ALL' >> /etc/sudoers cp /etc/sudoers /tmp chmod +w /tmp/sudoers printf '/^%%admin.*ALL = (ALL) ALL$/d\nw\nq\n' | ed /tmp/sudoers if visudo -c -...


3

For what it's worth, you can use printf '/^%%admin ALL = (ALL) ALL$/d\nw\nq\n' | ed -s sudoers or, if you want to catch the line independent of the number of space characters, tabs etc used printf '/^%%admin[[:blank:]]*ALL[[:blank:]]*=[[:blank:]]*(ALL)[[:blank:]]*ALL$/d\nw\nq\n' | ed sudoers in bash to remove the admin line (the double %% are required ...


1

I've had the same issue. I don't know if it's encouraged, but you can use the "-w" flag to "allow destructive actions." This seems to have fixed the issue for me. However I have no idea what the consequences are. I'm running a very simple script though, so I'm reasonably confident that I'm not doing anything that is very "destructive." This was hard to find,...


0

Your command ping -c 3 www.google.com should have produced 3 internet response packets of the type ICMP ECHO REPLY. The ping command sends ECHO packets using the ICMP protocol, and the responses (if any) are ECHO REPLY packets. The curl command on the other hand, sends HTTP packets using the TCP protocol. Since the latter works and the former doesn't, there ...


5

I prefer to use the system configuration utility tool to test for reachability instead of using ping / host / nslookup or another proxy for determining if a network entity is or is not reachable. scutil -r google.com Reachable The benefits of this are that if you have VPN connections, dial up, modem, or a routing conflict, this will actually test that you ...


4

Your problem is that you're using invalid options for the ping command. It seems likely that you have copied a command line intended for use on Linux, and tried to use it unmodified on macOS. The specific problem here is that Linux uses "-w" to specify timeouts, whereas macOS uses "-t". This means that your command line should instead be this: ping -q -t1 -...


3

I’ve found confirmation in the commit history: it’s a bug, which was fixed in r338375 in August 2018.


1

I believe you're using su or similar to login to the root account while in your normal account. While you are using Terminal, any action taken in the Terminal.app will have the same root user level access. However, once you leave the Terminal.app, such as when you use the open command, that opened app does not inherit the special permissions from root. It ...


0

Assuming you have a WindowServer (as the scrutil, setgetscreenres and displayplacer answers assume, and true under Mojave even with ⌘-S), you can also try the displaymode command-line utility to change the resolution. Grab it from: https://github.com/p00ya/displaymode To change the resolution to 1280x800, run it like: ./displaymode t 1280 800 This is a ...


0

To actually answer the original question regarding single-user (text) mode: the resolution of the text console is typically a kernel parameter (e.g. on linux it's the vga= parameter). I don't have a pre-Mojave system to test on, but see this description of boot-args, which implies you may be able to get VGA-res with: sudo nvram boot-args="Text Mode" or ...


1

[Not a full answer; not re CLI] I don’t know if the transfer is possible in a useful manner, but look at iExplorer from Macroplant & especially its feature to use device as USB drive. Whatever limitations exist to this (e.g., no root directory access) would suggest to me that those limitations are fundamental to iOS.


1

I would suggest you use ssh-copy-id to grant your computer automated ssh access to the remote server of your choice. The utility is found under /usr/bin/ on most systems (including recent versions of macOS). On older macOS versions you can run cat ~/.ssh/id_rsa.pub | ssh johnfoo@0.0.0.0 "[ -d ~/.ssh ] || mkdir ~/.ssh; cat >> ~/.ssh/authorized_keys"...


0

I didn't test it with Lion, but there is a high probability that control+d would delete the character to the right of the cursor, and control+k would delete everything to the end of line.


1

If you don't want to install homebrew, you can install keka (which is an excellent gui for (un)compressing btw) and then link to the included version of p7zip found at Keka.app/Contents/Resources/keka7z In order to make it function from the command line, I symlinked it into my /usr/local/bin > ln -s /Applications/Keka.app/Contents/Resources/keka7z /usr/...


Top 50 recent answers are included