I am new to computers and using the terminal. Most tutorials I look at for downloading tell me to go to usr/local/src. However, I don't find this on mac. Should I just make a directory called src?
Or is this something specific only to linux users?
If someone could tell me how much difference it makes for this directory to exist or not that would be great. Can I complete my installations in usr/local itself?
Thanks
Using the Finder, you can press Cmd-Shift-G and type /usr to display that folder. The /local folder is there by default, but not its /src subfolder. The Finder, of course, can easily create it for you.
As #cricket_007 mentioned, you need to be certain of what you're doing in this area of the system — that's why OS X doesn't display those folders by default. If you understand the risk and want to see everything in the Finder, you can issue the following Terminal command:
defaults write com.apple.finder AppleShowAllFiles YES
... then type:
killall Finder
and it will look like this. The hidden folders have a slightly faded appearance, but you can navigate into them as desired:
Alternatively (for High Sierra and above)
You may simply use the key combination: " Cmd Shift > " to toggle on and off hidden file display.
It depends what you are doing. If you're messing about just create one in your home directory:
$ cd ~
$ mkdir src
If you building stuff via configure etc., and you want to install it into /usr/local (the default install prefix), then just do this:
$ cd ~/src/packagename
$ ./configure ... options ...
$ make
$ sudo make install
Related
I make bash/ruby commands for basically everything in my development workflow (todo, pullrequest, asciiart, remind and so on). People I work with always ask me to share my commands with them, but to do this, I transfer the files to their computer, then xargs through each file with chmod +x and mv /usr/local/bin.
Wondering what work I can do upfront to make the import process easier. Fine with some Mac installer tool, or a git & makefile solution, but I'd really like to get the process down to a single click or command if possible.
Use Nix expressions with Nix package manager: https://en.m.wikipedia.org/wiki/Nix_package_manager ! It is supported on Macs.
It is possible to make a Terminal command executable by just selecting it in Finder and pressing the keyboard shortcut.
Below is the method for solving your problem.
1. Create a macOS service using Automator
1.1 Open Automator and create a new service
1.2 At the top, choose Service receives selected no input in Finder
1.3 Drag Get Selected Finder Items action to the workflow
1.4 Drag Run Shell Script action to the workflow
1.5 In Run Shell Script action, select Pass input: as arguments and in the text field, type:
chmod u+x "$#" && mv "$#" /usr/local/bin
1.6 Save service
2. Distribute service to colleagues’ computers
2.1 The created service is located in ~/Library/Services
2.2 Move it to other computers and install it by opening the file, or manually copying the service to ~/Library/Services
3. Bind service to a keyboard shortcut
3.1 Open System Preferences → Keyboard → Shortcuts → Services → General
3.2 Choose an appropriate keyboard shortcut for your service
You can also run the service by right-clicking on file and selecting the action in Services submenu at the bottom of contextual menu.
Share a Dropbox directory with them that contains your scripts, and ensure that it is in their PATH.
No updates are necessary when you improve your scripts as they will automatically see the latest version.
Manage the directory with git for version control.
Thought I'd post the standard makefile solution for completion sake. Works for macOS/ and GNU(Linux)
Put a makefile in the project directory.
So the directory looks like [ my-executable makefile readme.md ] or whatever
# makefile
install:
# side note: `#` prevents make from printing the command itself
#echo "installing..."
#chmod +x my-executable
#cp my-executable /usr/local/bin
#echo "done!"
then inform recipients to download/clone and run sudo make install from the project directory
Or for a one-line solution (presuming the recipients trust you a little too much)
git clone https://githost.com/myaccount/myrepo.git &&
sudo make install -C myrepo &&
rm -rf myrepo
(download, install, remove cloned directory) – user 16 mins ago
To hide the bitnami banner, google recomment to run
sudo ./bnconfig --disable_banner 1
But in MacOS it is bnconfig.app and so I am not able to run this. changing this to
sudo ./bnconfig.app --disable_banner 1
also failed.
How can I do this in macOS
.app folders on OS X are a bit peculiar. From the finder they look like programs, but in the terminal they are actually just folders.
It seems like this is the way to configure Bitnami on Mac: https://docs.bitnami.com/installer/components/bnconfig/
In your case I think that means:
~/Documents/BITNAMI/odoo9/apps/odoo/bnconfig.app/Contents/MacOS/installbuilder.sh --disable_banner 1
If you need to run this with sudo, replace the ~ with the absolute path to your home folder. You can get it with (cd ~ && pwd).
oh my god...i faced a big problem...i was created a .bash_profile in ~ folder and then set paths there...bust the big problem is after restarting my bash i see that none of my commands work like LS and RM and etc...
now i dont know how to fix it...some one help me...i need my terminal as soon as possible...
Make sure you are appending to the existing $PATH.
PATH=$PATH:/Users/mthalman/bin
To prevent this happening in the future:
When I edit my environment files (including bashrc, profile, login, and others), I always try starting another shell before quitting my editing environment. This protects me from the possibility of breaking my environment so that I can't log in.
Make sure your PATH includes the usual bin directories: /bin and /usr/bin.
First I would rename ~/.bash_profile to ~/old.bash_profile.
Then open that up in TextEdit (as a plain text document) and verify how you have set your path.
If you would prefer to use vim/emacs/nano/whatever, the act of renaming the file will allow new terminal sessions to use default paths, so from the command line you should be mostly fine.
Then verify you haven't clobbered $PATH as suggested by #Mark Thalman, above.
If you are in a Terminal Window, simply add in the /bin and /usr/bin back in your PATH.
$ PATH="/bin:/usr/bin:$PATH"
That should allow all the basic Unix command to work once more. Or, you can use the full path name for commands:
$ PATH="" #Can't find nothin'
$ ls
bash: ls: command not found.
$ /bin/ls -a #This will work!
. .. .bash_profile foo bar
Don't Reset PATH in your .profile!
As you discovered, you should never reset PATH in your `.bash_profile. Instead, you should always append and prepend to it:
PATH="/usr/local/bin:$PATH"
PATH="$PATH:$HOME/bin"
The first line will prepend /usr/local/bin to PATH which means if a command is in /usr/local/bin and /usr/bin, the /usr/local/bin version will be executed. Many system admins will put alternative base system commands in /usr/local/bin. For example, on Solaris, they might put VIM in /usr/local/bin/vi, so when you edit a file, you're using the improved VIM and not the base VI.
The second line appends your $HOME/bin to the end of $PATH. That means if there's a /bin/ls and you have ~/bin/ls, the /bin/ls will be executed first.
Never set PATH from scratch because each Unix system might have commands that you to access elsewhere in the system. For example, your site might require you to use X11, so you want /usr/X11/bin in your PATH, or you have GIT installed under the /opt/git directory, and you'll need /opt/git/bin in your path.
Sometimes, base utilities like ls might be replaced with upgraded versions of these utilities. On Solaris, you have the base vi and ls command, Most users like the GNU ls command because it uses color and prefer VIM to plain VI. I would included these utilities in /usr/local/bin and prepend that to my PATH.
And now a Word from a Sponsor
As you probably discovered, Finder doesn't list hidden files. That's why you can't see .bash_profile in Finder. You can use some hacks to change this, but it requires you to type them into the terminal window.
I use a Finder replacement called Path Finder. It contains a lot of neat Power User things such as allowing you to see hidden files, treat Packages such as apps as directories, and be able to view protected directories if you have Administrator access. There's a built in terminal and GUI Subversion client.
It's not cheap ($40), but you can download for free and try it out for 30 days.
BTW, I have absolutely no relationship to Cocoatech except as a customer, and I make no money from people buying Path Finder. It's just a tool I use.
Looking for a solution to quickly navigate to long paths in a shell (particularly Max OS X Terminal.app).
Say my path is ~/This/Is/A/Really/Long/Path/That/I/Would/Rather/Not/Type/Frequently
Instead of cd ~/This/Is/A/....
I would like to be able to store favorites/bookmark directories so I could do "cd myPath"
Are there any binaries or tools available to do something like this?
I've found the packages 'Apparix' and 'Goto' which together make the stuff dreams are made of for us terminal junkies.
Naturally, I had trouble installing Apparix, but I figured it out in the end.
How To Install Apparix on Mac OS X:
Download the tarball from Apparix's homepage.
Unpack the tarball, cd to the unpacked folder.
Run this command ./configure --prefix=$HOME/local && make && make install.
Run man apparix, scroll down to the heading BASH-style functions, copy everything within that section (delimited with ---) and paste it into ~/.bash_profile.
That's it. You should now have Apparix up and running on OS X (further install info and usage is on Apparix's homepage).
Another solution is to use Bashmarks, which allows you to this
$ cd ~/This/Is/A/Really/Long/Path/That/I/Would/Rather/Not/Type/Frequently
$ s shortname # save current path as `shortname`
$ cd /
$ g shortname # cd to ~/This/Is/A/Really/Long/Path/That/I/Would/Rather/Not/Type/Frequently
You can use aliases (stick them in your ~/.bash_profile if you want them to always load)
alias cd_bmark1='cd ~/This/Is/A/Really/Long/Path/That/I/Would/Rather/Not/Type/Frequently'
Then use by just typing
cd_bmark1
into the console
I know you already found an answer that worked for you, but a couple of more lightweight suggestions that might help others looking for similar things
If your directories are relatively fixed, just long and far away from each other, you can use the CDPATH environment variable to add directories to the search path when typing the "cd" command. If the directory name you try to cd to isn't in the current directory, the other entries in your CD path will also be looked at (and it's also tab complete aware, at least in bash and zsh).
Switching to zsh rather than bash and using the excellent directory stacks abilities. With it, you can maintain a history of directories that you've visited, view the history with the "dh" alias, and easily switch to a directory by using quick shortcuts (ex: cd -3 to switch to the 3rd directory in your history stack).
Why not having a symlink ?
ln -s ~/This/Is/A/Really/Long/Path/That/I/Would/Rather/Not/Type/Frequently bmark
cd bmark
I use to.sh daily to create and navigate bookmarked paths in bash. It supports tag autocompletion and the ability to easily add/remove bookmarks.
https://github.com/Grafluxe/to.sh
Full disclosure, I wrote this tool :)
After searching online, the best solution I've found so far is to just make a symbolic link in either "/Library/logs/" or "~/Library/logs/" to get it to show up in the Console application.
I'm wondering if it would be possible to add a new directory or log file to the "root" level directly under the "LOG FILES" section in the console.
Here's a quick screenshot:
There is one way to get your log files into the console.
You can add a symlink to the log file or log directory to one of the directories in the list. The directory ~/Library/Logs seems like the logical choice for adding your own log files.
For myself I wanted easy access to apache2 logs. I installed apache2 using macports and the default log file is located at /opt/local/apache2/logs.
Thus all I did was create the symlink to that directory.
# cd ~/Library/Logs
# ln -s /opt/local/apache2/logs/ apache2
Now I can easily use the console.app to get to the logs.
My solution for macOS Sierra:
First and last step, you must create a hard link from your source (log) directory into (as example) one of existing official log directories, you can seen in console.app.
I take my ~/Library/Logs directory for that.
hln /usr/local/var/log /Users/dierk/Library/Logs/_usr_local_var_log
Cross-posting this great tool for creating hardlinks originally posted by Sam.
Short intro:
To install Hardlink, ensure you've installed homebrew, then run:
brew install hardlink-osx
Once installed, create a hard link with:
hln [source] [destination]
I actually just came across this option that worked perfectly for me:
Actually if you open terminal and...
$ cd /Library/Logs
then sym-link to your new log directory. eg i want my chroot'ed apache logs as 'www'
$ ln -s /chroot/apache/private/var/log www
then re-open Console.app
drill down into /Library/Logs and you will find your sym-linked directory.
;-)
Mohclips.
http://forums.macosxhints.com/showthread.php?t=35680
In Terminal run this command... append any log file directories you want to add
defaults write com.apple.Console LogFolderPaths -array '~/Library/Logs/' '/Library/Logs/' '/var/log/' '/opt/local/var/log/'
Since Mavericks, symlink behavior as change so "ln - s" doesn't work anymore.
use hardlink-osx instead to create an hardlink to your directory (may be installed via homebrew)
Very old post I know but, this is the only way I could get it to work.
cd /Library/Logs
sudo mkdir log_files
sudo ln -s /Users/USERNAME/Sites/website/logs/* log_files
In mac os 10.11, you may not be able to link to folder of logs, but instead you need to link to each log of logs folder in side console.
ln -s /opt/local/apache2/logs/error_log ~/Library/Logs/Apache2/error_log
You can just open any text file with console.app and it will add and keep it. Folder's though, no luck on that yet.
I was able to hardlink the files into ~/Library/logs by running:
ln /usr/local/var/logs/postgres.log ~/Library/logs
Notice the absence of -s.
No luck for directories though.
OSX Sierra 10.12.6
Just tried to do something similar.
I enter this in terminal, while the Console.app was running.
sudo mkdir -p /usr/local/var/log/apache2
sudo mv /private/var/log/apache2 /usr/local/var/log/apache2/apache2-old
sudo ln -s /usr/local/var/log/apache2 /private/var/log/apache2
Now whenever I open the Console.app it crashes.
Really wish there was a way of adding log files in the files. You CAN do it by dragging and dropping a folder onto the Console.app (given it a directory path as an argument), but the added folder only displays its immediate contents and doesn't allow for recursively descending into folders.
---------EDIT BELOW----------
Nevermind I stupidly did something like this leading to infinite recursion in Console.app
sudo mkdir -p /usr/local/var/log/apache2
sudo ln -s /private/var/log/apache2/apache2 /usr/local/var/log/apache2
sudo mv /private/var/log/apache2 /usr/local/var/log/apache2/apache2-old
sudo ln -s /usr/local/var/log/apache2 /private/var/log/apache2
I don't believe it's possible.
If you're generating log files, you should generate them into one of the standard locations anyway, so this won't be an issue.