What is 'dev' folder when using zsh - terminal

I'm currently using macOSX
and I just installed oh-my-zsh for using customized UI like 'robbyrussell'
After using zsh, I ran across some folder called 'dev'
- full absolute path is /dev
it wasn't exist in '/' until I've used in just normal terminal ( not zsh )
What is 'dev' folder for?

dev is short for devices. On Unix systems (MacOS is a derivate of UNIX via NextStep and BSD) /dev contains file representations of peripheral devices (disks, keyboards, terminals, etc.) and pseudo-devices (random number generators (/dev/random, /dev/urandom), Null-file (/dev/null), etc.).
Have a look at the hier manpage (man 7 hier) for some information on the filesystem hierarchy.
I am not sure why /dev would not have shown up before. It is usually hidden in Finder but should be visible in the terminal, no matter which shell.

Related

How to translate the wslpath /home/user/ to windows path

I use Linux subsystem of windows 10(windows 10 version 1803)
I can use command line:
user#laptop:~$ wslpath -w /c/
C:\
But when I try to use
user#laptop:~$ wslpath -w ~
wslpath: /home/user: Result not representable
Even I use:
user#laptop:~$ wslpath -w /home/user
wslpath: /home/user: Result not representable
why?
how to translate the /home/user to windows path?
my home folder path in windows is C:\Users\winuser\AppData\Local\lxss\home
I expect some command line can give me return that string.
Updated guidance for users of Windows 10 1809 or later:
In Windows 10 1809, we (finally) shipped filesystem integration allowing you to access the files in your WSL distros from Windows via the \\wsl$ UNC path:
If you're interested in the details behind how this works, please visit this blog post: https://devblogs.microsoft.com/commandline/a-deep-dive-into-how-wsl-allows-windows-to-access-linux-files/
This now allows wslpath to provide a Windows-accessible path to files within your distro's filesystem:
In the up-coming Windows 10 May 2020 Update (2004), you won't have to remember the somewhat obscure \\wsl$\ UNC path - instead you'll just click on the Tux (Linux penguin) icon in your File Explorer:
Warning for WSL1 users:
Do not try to spelunk to the %localappdata%\lxss\... folders containing your WSL1 Linux files from Windows - there be dragons!
Please read this post: https://blogs.msdn.microsoft.com/commandline/2016/11/17/do-not-change-linux-files-using-windows-apps-and-tools/
This guidance has not, and will not change, though it will become less important over time: In particular, WSL2 does not use %localappdata%\lxss - instead it stores your linux files within EXT4 formatted VHDX files delivering near-native IO performance for the distro's local filesystem.
To convert a WSL Linux path to a Windows path use wlspath -w. For example:
$ wslpath -w /mnt/c/Users
C:\Users
$ wslpath -w /usr/bin
\\wsl$\Debian\usr\bin
(Yep, the answer is in the question, but some people, like me, are going to skip straight to the answers without reading the question.) The problem reported by the OP doesn't exist in WSL2.

Best strategy for installing cygwin under restrictive IT policies?

My organization has a group policy in effect that will only allow executable programs to reside under the Program Files (or Program Files X86) directory. Obviously, these directories are not writable by normal users. I have access to local admin rights, so I can install things there if I want. But of course it doesn't make sense to put the whole cygwin tree there, since users need to be able to write to /home, /tmp, etc. I am thinking I might be able to do something with links, maybe install to c:\cygwin, then move just the /bin directory under Program Files and create a hard link to it?
Has anyone run into a similar situation and come up with an elegant solution? This is Win 7 Enterprise.
Prior to Cygwin 1.7.34, solving such problems required a fair bit of hoop-jumping,¹ but now it's easy:
If you haven't installed Cygwin yet, do so.²
If you have Cygwin installed already and you started with a version of Cygwin prior to 1.7.34, move /etc/passwd and /etc/group out of the way,³ then upgrade to the current version.
Start the Cygwin Terminal.
Open Cygwin's /etc/nsswitch.conf in your favorite text editor.⁴ Add a line like this:
db_home: /%H
That's it! When you next re-start Cygwin, it will treat your Windows profile directory as your Cygwin home directory.⁵ This means you will have useful sub-folders like Desktop and Downloads as sub-folders, which matches the way OS X and a lot of desktop Linuxes work.
Some people might not want these two directories to be treated as equivalents. You can choose any path scheme you like. For example, you could change it to /cygdrive/c/Users/%U/cygwin to put your Cygwin home folder into a cygwin subdirectory of your Windows profile directory.
This new feature of Cygwin is very powerful and can do a lot more than I show here. For example, you can change a Cygwin user home directory via AD instead, if you like. See that documentation for details.
You might also want to rearrange a few other elements of the Cygwin path scheme. You can do so by editing Cygwin's /etc/fstab file. You probably want to move /tmp, /usr/tmp, and /var/tmp to a directory that non-admin users can write to, for one thing:
c:/tmp /tmp ntfs auto 0 0
c:/tmp /usr/tmp ntfs auto 0 0
c:/tmp /var/tmp ntfs auto 0 0
This will let you install (and later update) Cygwin as an Administrator while still letting unprivileged users run Cygwin. This makes Cygwin behave more like Linux or Unix. Since most software in the Cygwin package repository comes from that world, you can count on it to behave correctly under such a scheme.
Footnotes:
The first version of this answer tells you how to do an equivalent thing with older versions of Cygwin.
Cygwin doesn't care where you install it, so if the default doesn't work for you, feel free to change it. Some ideas:
C:\Program Files\Cygwin
C:\Users\jeremy\Cygwin
D:\cygwin
Cygwin will remember your choice on subsequent updates.
If you don't move these files out of the way, they interfere with the solution we build above. This part of Cygwin is complex enough to deserve a whole section in the Cygwin user manual. Hint. :)
Cygwin installs a stripped-down version of the Vim text editor by default.
If you don't like vi, there are many other text editors in the Cygwin package repository.
If you do like vi, I suggest installing the full version of Vim, then adding alias vi=vim to your ~/.bashrc.
You can also use a native Windows GUI text editor. Cygwin's /etc/nsswitch.conf parser appears to cope with DOS line endings.
The Cygwin DLL is building this path from the %HOMEDRIVE% and %HOMEPATH% environment variables, then converting it to POSIX form.

Filesetattr is not available with XE3 (Firemonkey)

I want create a hidden ini file under macosX environment with Firemonkey (XE3).
But unfortunaly this command is not known anymore in system.utilys
Somebody tips?
On a Mac, there are two ways to make file "hidden" or "invisible".
Like Linux or Unix, you can start the filename with a dot (.).
You can also use the setfile tool that ships with Xcode to set attributes to make it invisible ([setfile a -V filename][3]).
Depending on the way, you will have to replace the Win32 specific SetFileAttr call with a Mac specific rename, or find out which API setfile uses to set the attributes.
In UNIX (and in this layer Mac OS is largely spin-off from FreeBSD) there is no "hidden" flag on file, instead special files should have their name started with dot. http://en.wikipedia.org/wiki/Dot-file
So if you want to hide a file - rename it.
That is not the question about Delphi = that is the question of operating system, Windows vs UNIX.
Open console/terminal/whatever they call command prompt in Apple, go to ur home folder and issue two commands: ls and ls -a - compare the file lists in output.
Well, for starters you can do it in Linux - http://bellard.org/jslinux/ - wait few seconds for it to boot, then issue ls, ls -l, ls -a, ls -la and see the difference.
Dot-files are treated specially and hidden by default.

Where is the default terminal $PATH located on Mac?

I have been looking throughout the system but I cannot find it. When I do echo $PATH I get the stuff I added, plus the default path. I do not have a .profile, and I do have a .bashrc, but the default path is not in there. I am looking for it just to know where it is located because all the tutorials explain that its in .profile... but what if you don't have one? Where is it located then? Anybody have any ideas?
If you do sudo man path_helper, it talks a bit about how it puts the path together. You might look in /etc/paths and /etc/paths.d. I did, and found what I was looking for.
Many system-wide settings including PATH are set in /etc/profile which is read in by bash at startup. On Mac OS X this file usually uses path_helper to set PATH. This utility in turn reads the information from other system configuration files under /etc (see path_helper manpage).
Note that even if you disable the reading of the initialization files by bash (e.g. with command-line options like --noprofile) it will still inherit the environment of the parent process.
If you start at /etc/profile, it should look something like this:
if [ -x /usr/libexec/path_helper ]; then
eval `/usr/libexec/path_helper -s`
fi
It's testing to see if the file exists and if so, executes it. If you execute it by hand, you'll get something like this:
PATH="/usr/bin:/bin:/usr/sbin:/usr/local/bin:/usr/X11/bin"; export PATH;
I believe that's what you're looking for. So it comes from /etc/profile, which in turn calls an executable that sets the path.
As mentioned in the accepted answer, the $PATH is built by first looking into the content of the file /etc/paths, and then looking into every file in the folder /etc/paths.d. So, the $PATH in the pre-installed bash system installation contains every entry in these files, as well as in other shell types.
However, because in the latest Mac OS versions the default shell is zsh, I followed a couple of tutorials in which the writer avoided to change the $PATH for the bash shell, and simply added new entries to the $PATH by editing ~/.zshrc the following way:
export PATH=/path/available/only/for/zsh/shells:$PATH
The above command adds /path/available/only/for/zsh/shells to the $PATH, and the added path will only be available in zsh shells.
I hope this helps someone who, like me, had too many entries in the $PATH in zsh shells, and couldn't figure out where they were coming from!
The .profile file on Mac is located in your user folder: ~/Users/youruser/
However, the .profile file is hidden. You can press Command+shift+. (command, shift, dot) while on Finder to see them.
There's one important fact I only realized today while debugging a problem: the profile settings (.bash_profile etc.) are only read by login shells. They are not read by the processes that are used to launch your applications.
You launch your applications in diverse ways: click the icon in /Applications, or type the name in Spotlight search, or click an icon in the Dock ... In all those cases, the application itself (i.e the binary or shell script inside the application) is launched by launchd without any parent shell. Meaning that your profile is not run and that your custom settings (PATH, environment variables ...) will be ignored.
That can cause all sorts of trouble, for example if you setup you environment to use a specific version of Java: your application will not see that and use the "default" java, which will be the one with the highest version number.
In my case, the problem is that my application was crashing when run via the application launcher, but runs fine when run from a terminal window ... The reason was that I had a custom path that included some libraries required by the application, but that was not available when the application was run by the launcher.
The solution I used was to symlink the libraries needed into /usr/local/lib

Issues with Mac OS X's resource fork file "._uf029" for usage of .VolumeIcon.icns

There are a lot of guides out there on creating custom icons, but the challenge I have experienced is how to put .VolumeIcon.icns on some sort of mass produced volume (like a flash drive) so that all Macs after 10.4 use it.
OS X consistently creates something called a resource fork file for .VolumeIcon.icns which tells future Macs its mounted on to use it. This file, when I produced it on various Macs, has consistently been ._ follow by the special use character "uf029" in its filename - and this is where the problem lies. This file, therefore, shows up on Windows as ._? on OSX as . _ . (without the spaces, I'm guessing stackoverflow needs an escape char) and various other ways in different places. This file is required for .VolumeIcon.icns to work, it is always 4k, and seems to be composed of some proprietary encoding.
This is a vary hard file to manage, but I got around this on git by first zipping it - otherwise it isn't even recognized as a file (even though you can list it in a dir with ls -a, ls [filename] returns some variation of a file not found error, since its a resource fork file). More on that here.
I'm wondering how Ipods, for example, I've plugged in tell OS X to use the .VolumeIcon.icns file without this resource fork file (I see no ._. file when I ls -a the Ipod). How do other people distribute Volumes with a VolumeIcon to Mac users without this problematic file? Another way is to set a VolumeIcon attribute using the OS X dev tool "SetFile -a C /Volumes/name"
Any Apple developers out there know of a work around?

Resources