MacOS Catalina - Show all directories from root in Finder - macos

As a reluctant Mac user, I am routinely frustrated by things that should be very simple. Finder is one of those. When trying to open an XML file from Firefox, I am asked what application I whish to open it with. Obviously MacVim. To do that, I need to navigate to /usr/local/bin/gvim which is a symlink to /Cellar, since it was installed with HomeBrew. However, when I select "Open with" and click "Choose", the Finder comes up and defaults to Applications. It's not in there, I just want to navigate directly to the symlink. Switching to "Macintosh HD" (also known as "/" to a more refined audience) only displays Application, Library, System, and Users. Where is everything else? Where is /usr, /bin, /etc? As a user, this seems disingenuous. It's not an accurate representation of my location in the filesystem. Sorry, this is a bit of a rant, but also a legitimate question. How do I display these all the time?

The UNIX (lowercase) directories are hidden from view, intentionally, through a special "hidden" flag. You can see those in ls -lO:
Chimera:~ morpheus$ ls -lO /
total 14
drwxrwxr-x+ 59 root admin sunlnk 1888 Sep 23 16:46 Applications
drwxr-xr-x+ 65 root wheel sunlnk 2080 Mar 20 2020 Library
drwxr-xr-x 2 root wheel hidden 64 Sep 30 2018 Network
drwxr-xr-x# 5 root wheel restricted 160 Sep 21 2018 System
drwxr-xr-x 7 root admin - 224 Mar 20 2020 Users
drwxr-xr-x# 8 root wheel hidden 256 Sep 23 21:17 Volumes
drwxr-xr-x# 37 root wheel restricted,hidden 1184 Mar 27 2019 bin
drwxrwxr-t# 2 root admin hidden 64 Feb 8 2019 cores
dr-xr-xr-x 3 root wheel hidden 4821 Aug 30 19:38 dev
lrwxr-xr-x# 1 root wheel restricted,hidden 11 Sep 30 2018 etc -> private/etc
dr-xr-xr-x 2 root wheel hidden 1 Sep 24 07:59 home
-rw-r--r-- 1 root wheel hidden,compressed 313 Aug 17 2018 installer.failurerequests
drwxr-xr-x 2 root wheel - 64 Oct 3 2018 mnt
drwxr-xr-x 2 root wheel - 64 Jan 21 2018 mnt1
dr-xr-xr-x 2 root wheel hidden 1 Sep 24 07:59 net
drwxr-xr-x 6 root wheel sunlnk,hidden 192 Sep 30 2018 private
drwxr-xr-x# 64 root wheel restricted,hidden 2048 Mar 27 2019 sbin
lrwxr-xr-x# 1 root wheel restricted,hidden 11 Sep 30 2018 tmp -> private/tmp
drwxr-xr-x# 9 root wheel restricted,hidden 288 Sep 21 2018 usr
lrwxr-xr-x# 1 root wheel restricted,hidden 11 Sep 30 2018 var -> private/var
Additionally, Finder will not display hidden "." files, the same way ls -l needs to be "persuaded" using -a (try "ls -lOa /", omitted here for brevity).
Pressing the apple key along with shift and '.' will display everything. To make this the default behavior:
defaults write com.apple.finder AppleShowAllFiles YES
In case you're interested in the rationale - it dates back to NeXTSTEP (the progenitor to MacOS X and later as we know it now), which wanted to provide a user interface to its own (Uppercase first letter) directories, while hiding those of the underlying UNIX (BSD layer), seeing as non-root users have nothing to look for there, anyway (and most users have no knowledge of terminal/shell).

Related

Force rotate a certain log file without using logrotate

I am trying to force rotate a specific log, e.g., /mroot/etc/mlog/sktrace.log.
For example, currently here are all the logs related to sktrace:
<machine_name>% ll /mroot/etc/mlog/sktrace*
-rw-r--r-- 2 root wheel 13276789 Oct 16 13:00 /mroot/etc/mlog/sktrace.log
-rw-r--r-- 1 root wheel 3063670 Oct 13 10:42 /mroot/etc/mlog/sktrace.log.0000000001
-rw-r--r-- 1 root wheel 44072508 Oct 14 10:42 /mroot/etc/mlog/sktrace.log.0000000002
-rw-r--r-- 1 root wheel 96622284 Oct 15 10:42 /mroot/etc/mlog/sktrace.log.0000000003
-rw-r--r-- 1 root wheel 104858396 Oct 16 08:54 /mroot/etc/mlog/sktrace.log.0000000004
-rw-r--r-- 1 root wheel 10466192 Oct 16 10:42 /mroot/etc/mlog/sktrace.log.0000000005
-rw-r--r-- 2 root wheel 13276789 Oct 16 13:00 /mroot/etc/mlog/sktrace.log.0000000006
By “force rotate”, I mean to copy the content in the current /mroot/etc/mlog/sktrace.log to /mroot/etc/mlog/sktrace.log.0000000007, and then truncate /mroot/etc/mlog/sktrace.log to 0-byte.
The decent way is probably via logrotate. But it is not available on the system I am using:
<machine_name>% which logrotate
logrotate: Command not found.
<machine_name>% ll /usr/sbin/logrotate
ls: /usr/sbin/logrotate: No such file or directory
What's the best alternative in bash, please?

What directories does Linux have that macOS doesn't?

I'm a Python programmer that is trying to make a system of sorts that creates save data for a game I'm making, and I want it to be in different places in something like Ubuntu than I do macOS. As I don't have a macOS, and it's impossible to just up and get an ISO to get a macOS VM, I can't look through the files and folders and see what it has (or doesn't) that Linux does or doesn't.
I've tried looking all over to the point of attempting to get a hold of an ISO to build a VM in VirtualBox, but haven't been successful at all.
What files or folders does macOS have that Linux does, or vice versa?
To complete the (excellent) answer from #Michael, here is the listing of the home and root directory after a fresh install on the latest stable release of MacOS System (10.14.2)
MacBook-Pro:~ max$ ls -al /
total 37
drwxr-xr-x 26 root wheel 832 Jan 6 19:00 .
drwxr-xr-x 26 root wheel 832 Jan 6 19:00 ..
-rw-rw-r-- 1 root admin 8196 Jan 13 07:11 .DS_Store
drwx------ 5 root admin 160 Jan 6 11:47 .Spotlight-V100
d-wx-wx-wt 2 root wheel 64 Jan 14 06:39 .Trashes
---------- 1 root admin 0 Aug 18 06:53 .file
drwx------ 11 root admin 352 Jan 14 06:39 .fseventsd
drwxr-xr-x 2 root wheel 64 Aug 18 06:53 .vol
drwxrwxr-x+ 39 root admin 1248 Nov 30 12:49 Applications
drwxr-xr-x+ 60 root wheel 1920 Nov 30 12:50 Library
drwxr-xr-x 2 root wheel 64 Aug 18 06:53 Network
drwxr-xr-x# 5 root wheel 160 Nov 30 12:46 System
drwxr-xr-x 5 root admin 160 Jan 6 18:59 Users
drwxr-xr-x+ 4 root wheel 128 Jan 14 06:39 Volumes
drwxr-xr-x# 37 root wheel 1184 Nov 30 12:55 bin
drwxrwxr-t 2 root admin 64 Aug 18 06:53 cores
dr-xr-xr-x 3 root wheel 4301 Jan 14 06:39 dev
lrwxr-xr-x# 1 root wheel 11 Jan 6 18:49 etc -> private/etc
dr-xr-xr-x 2 root wheel 1 Jan 14 06:40 home
-rw-r--r-- 1 root wheel 313 Aug 18 10:03 installer.failurerequests
dr-xr-xr-x 2 root wheel 1 Jan 14 06:40 net
drwxr-xr-x 6 root wheel 192 Nov 30 12:50 private
drwxr-xr-x# 64 root wheel 2048 Jan 6 18:49 sbin
lrwxr-xr-x# 1 root wheel 11 Jan 6 18:49 tmp -> private/tmp
drwxr-xr-x# 9 root wheel 288 Nov 30 12:38 usr
lrwxr-xr-x# 1 root wheel 11 Jan 6 18:49 var -> private/var
And the home dir:
MacBook-Pro:~ max$ ls -al ~
total 16
drwxr-xr-x+ 15 max staff 480 Jan 14 06:43 .
drwxr-xr-x 5 root admin 160 Jan 6 18:59 ..
-r-------- 1 max staff 7 Jan 6 18:59 .CFUserTextEncoding
drwx------ 2 max staff 64 Jan 14 06:40 .Trash
-rw------- 1 max staff 0 Jan 13 07:11 .bash_history
drwx------ 10 max staff 320 Jan 14 06:40 .bash_sessions
-rw------- 1 max staff 908 Jan 14 06:43 .viminfo
drwx------+ 3 max staff 96 Jan 6 18:59 Desktop
drwx------+ 3 max staff 96 Jan 6 18:59 Documents
drwx------+ 3 max staff 96 Jan 6 18:59 Downloads
drwx------# 51 max staff 1632 Jan 13 07:11 Library
drwx------+ 3 max staff 96 Jan 6 18:59 Movies
drwx------+ 3 max staff 96 Jan 6 18:59 Music
drwx------+ 3 max staff 96 Jan 6 18:59 Pictures
drwxr-xr-x+ 4 max staff 128 Jan 6 18:59 Public
Application settings on macOS are ususally saved somewhere in ~/Library: Common places are ~/Library/Preferences/com.example.mycoolgame.plist for preferences (should be in plist format and "com.example.mycoolgame" should be a valid bundle ID that you own (you should own the domain)). The advantage/disadvantage of this path is that power users know about this directory and can edit the files there as they wish.
Then you have ~/Library/Caches for cached data. All cached data should be put somewhere under this directory. (Never use it for content that cannot be regenerated or redownloaded though.)
~/Library/ApplicationSupport/YourApplicationName/...: here you can basically do anything you like. It would be good if "YourApplicationName" would be globally unique in this case.. So better make it long. Users usually don't see the filesystem contents of anything below "~/Library", so there is no need for short names.
Of course, you can also put your savegames in ~/Documents/MyCoolGame/savegames and tell the user that you save the games there.
A gotcha (maybe): I'm not sure if system APIs expand "~" properly. I think probably not: Calling fopen with a path that starts with "~" would most likely not do the right thing. The users directory is located at something like "/Users/max", so "~" expands to "/Users/max" in the command line if the username is "max".
I can't answer your original question "What directories does Linux have that macOS doesn't?" because I don't have a Linux box at hand at the moment, and I don't think that it would be helpful for your use case.
For global data, there is also the "/Library" hierarchy.. But normal users don't have access to this place, so your game would need to ask for admin rights, which will make everything much more complicated, and this will feel user-unfriendly to macOS users. The macOS way is to have a self-contained application bundle and put all user-specific or temporary data into the appropriate place within the users home folder.

How to remove the static message that appears when opening a Linux shell?

How to remove the following message:
To run a command as administrator (user "root"), use "sudo ".
See "man sudo_root" for details.
Every time I open a Terminal it appears. I upgraded from Ubuntu 14.04 LTS to 16.04 LTS and it seems that update made that.
I am using bash.
I googled that and found this command:
$ touch ~/.hushlogin
Execute the below command and close the terminal. The message will be remove from the terminal.
sudo apt-get update
atleast my ubuntu 14.04 machine will display(or run) all the script in /etc/update-motd.d(motd => message of the day) directory.
ll /etc/update-motd.d/
total 40
drwxr-xr-x 2 root root 4096 Sep 27 2014 ./
drwxr-xr-x 109 root root 4096 Nov 30 10:27 ../
-rwxr-xr-x 1 root root 1220 Feb 20 2014 00-header*
-rwxr-xr-x 1 root root 1358 Feb 20 2014 10-help-text*
lrwxrwxrwx 1 root root 46 Sep 27 2014 50-landscape-sysinfo -> /usr/share/landscape/landscape-sysinfo.wrapper*
-rwxr-xr-x 1 root root 334 Sep 27 2014 51-cloudguest*
-rwxr-xr-x 1 root root 149 Aug 22 2011 90-updates-available*
-rwxr-xr-x 1 root root 299 Aug 21 2014 91-release-upgrade*
-rwxr-xr-x 1 root root 111 Mar 27 2014 97-overlayroot*
-rwxr-xr-x 1 root root 142 Aug 22 2011 98-fsck-at-reboot*
-rwxr-xr-x 1 root root 144 Aug 22 2011 98-reboot-required*
The scipt with lowest number is gonna execute first 00-header*

Bash - What is the best way to save the value of a quantity after the script has terminated?

I am attempting to write a script that changes my desktop wallpaper to the next picture in my ~\Picture\Wallpapers directory. I have already created a script, change_wallpaper, which can change my desktop background to any given picture.
My plan was to list all the pictures in ~\Picture\Wallpapers as an array, find the index i of the current wallpaper, and apply change_wallpaper to the i+1 element of the array of pictures. My only issue is finding a way to story the index of the current wallpaper. I could create a file which contains this value, but it seems really inelegant to just have a text file with the number 12, for example, saved somewhere in my home directory.
Is there a better way?
I agree with the general consensus of using a file to store the index of the current wallpaper. A slightly more elegant way would be to put a "." (dot) in front of the file name to keep it hidden in the directory where your script is located. Something like:
admin#myHost:/home/admin$ ls -la
total 6200
drwxrwxr-x 4 admin admin 4096 Jul 02 15:41 .
drwxr-xr-x 71 bin bin 4096 Jun 29 12:43 ..
-rw------- 1 admin admin 3939 Jun 29 16:02 .bash_history
-rw-r--r-- 1 admin admin 21 Nov 04 2014 .bashrc
-rwxr-x--x 1 admin admin 259 Oct 13 2014 .profile
-rw------- 1 admin admin 3939 Jun 29 16:02 .wallpaper_index
-rw------- 1 admin admin 3939 Jun 29 16:02 change_wallpaper
There are countless linux and unix applications that do this.

Installing Torch7. iPython installation error (mac)

I'm trying to install Torch7 on my mac, however the installation halts at this point:
Not updating your shell profile.
You might want to
add the following lines to your shell profile:
export PATH=/Users/khsiddiqui/torch/install/bin:$PATH
export LD_LIBRARY_PATH=/Users/khsiddiqui/torch/install/lib:$LD_LIBRARY_PATH
export DYLD_LIBRARY_PATH=/Users/khsiddiqui/torch/install/lib:$DYLD_LIBRARY_PATH
Not sure what it means. Further above I received the following output
echo "Error: could not find ipython in PATH. Do you have it installed?"
fi
However iPython is installed as I can confirm:
No update necessary, 'ipython' is up-to-date.
ipython-3.0.0-3.egg was installed on: Thu Apr 9 18:12:32 2015
kamransiquisMBP:torch khsiddiqui$ env | grep PATH
PATH=/Users/khsiddiqui/Library/Enthought/Canopy_64bit/User/bin:
/usr/local/bin:
/usr/bin:
/bin:
/usr/sbin:
/sbin:
/opt/X11/bin:
/usr/texbin
Attempting to locate the .bashrc file
%edit .bashrc
WARNING: Argument given (.bashrc) can't be found as a variable or as a filename.
kamransiquisMBP:torch khsiddiqui$ ls -ld ~/.*
drwxr-xr-x+ 43 khsiddiqui staff 1462 12 Apr 01:15 /Users/khsiddiqui/.
drwxr-xr-x 6 root admin 204 19 Oct 17:34 /Users/khsiddiqui/..
-r-------- 1 khsiddiqui staff 7 19 Oct 17:34 /Users/khsiddiqui/.CFUserTextEncoding
-rw-r--r--# 1 khsiddiqui staff 16388 26 Mar 23:59 /Users/khsiddiqui/.DS_Store
drwxr-xr-x 3 khsiddiqui staff 102 8 Sep 2014 /Users/khsiddiqui/.R
-rw-r--r-- 1 khsiddiqui staff 728832 2 Apr 17:21 /Users/khsiddiqui/.RData
-rw-r--r-- 1 khsiddiqui staff 1101 20 Oct 02:58 /Users/khsiddiqui/.Rapp.history
-rw-r--r-- 1 khsiddiqui staff 6314 2 Apr 17:21 /Users/khsiddiqui/.Rhistory
drwx------ 22 khsiddiqui staff 748 12 Apr 01:25 /Users/khsiddiqui/.Trash
-rw------- 1 khsiddiqui staff 1860 9 Apr 22:15 /Users/khsiddiqui/.bash_history
drwxr-xr-x 4 khsiddiqui staff 136 9 Apr 17:57 /Users/khsiddiqui/.cache
drwx------ 18 khsiddiqui staff 612 12 Apr 20:09 /Users/khsiddiqui/.canopy
drwxr-xr-x 3 khsiddiqui staff 102 12 Apr 01:15 /Users/khsiddiqui/.conda
drwxr-xr-x 2 khsiddiqui staff 68 12 Apr 01:11 /Users/khsiddiqui/.continuum
drwx------ 3 khsiddiqui staff 102 30 Jul 2010 /Users/khsiddiqui/.cups
drwx------ 10 khsiddiqui staff 340 2 Apr 17:26 /Users/khsiddiqui/.dropbox
-rw-r--r-- 1 khsiddiqui staff 2525 12 Apr 16:56 /Users/khsiddiqui/.enstaller4rc
drwxr-xr-x 9 khsiddiqui staff 306 9 Apr 22:25 /Users/khsiddiqui/.ipython
drwxr-xr-x 4 khsiddiqui staff 136 12 Apr 16:57 /Users/khsiddiqui/.matplotlib
-rw-r--r-- 1 khsiddiqui staff 340 12 Apr 01:12 /Users/khsiddiqui/.profile
-rw-r--r-- 1 khsiddiqui staff 251 28 Mar 13:45 /Users/khsiddiqui/.profile-anaconda.bak
drwxr-xr-x 15 khsiddiqui staff 510 2 Apr 17:21 /Users/khsiddiqui/.rstudio-desktop
drwxr-xr-x 6 khsiddiqui staff 204 20 Oct 19:21 /Users/khsiddiqui/.subversion
-rw------- 1 khsiddiqui staff 625 9 Apr 21:33 /Users/khsiddiqui/.viminfo
i had a similar problem and solved it, maybe it could help others.
Here was the end of the second installation script, and the command "th" wasn't working:
Not updating your shell profile.
You might want to
add the following lines to your shell profile:
. /Users/myusername/torch/install/bin/torch-activate
This article explains how your shell profile is organized: https://serverfault.com/questions/110065/what-profile-is-my-current-shell-using
I realized in my user folder /Users/myusername/ i had a ".bash_profile" file, i pasted the line ". /Users/myusername/torch/install/bin/torch-activate" inside but didn't work (command "th" no recognized in terminal).
So in the same /Users/myusername/ folder i created a ".profile" file and pasted the line ". /Users/myusername/torch/install/bin/torch-activate" inside.
Then the command "th" works fine ;)
First, IPython may be installed but not seen by the install process.
If you enter which ipython at a shell prompt it will tell you where it is installed. Then echo $PATH will display your PATH variable which should contain the directory that contains IPython. If it isn't then you will have to edit the PATH statement in your .bashrc file to add it.
Second, .bashrc is a file that is run by the shell when it starts up and should be in your home directory so enter cd at a shell prompt and you will be there. Then use a text editor such as Text Edit to edit it. In your case you don't have a .bashrc file, instead some things are being set in a file called .profile. You should probably check the contents of that.
Finally, I wouldn't run any of these commands from within IPython. Only run them (and the Torch install process) from the shell.
Further, I notice you have a file with the name "anaconda" in it. Have you installed 'Anaconda'?

Resources