please help me out with mac OS 10.11 terminal commands [closed] - macos

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 6 years ago.
Improve this question
I'm new to using mac. Could someone please help me out with the terminal commands?
cd to jump into folders right?
i tried this but it isn't working for a folder in my desktop.
Basically, I want to enter a folder on my dekstop and then go to another folder inside that. how do i do it?

The Terminal starts in your HOME folder normally. So, type
ls
to list the files and you will see the same folders and files you see when you go to HOME in the Finder. So, you will see Desktop, so now type
cd Desktop
ls
and you will see all the folders and files on your desktop. If you want to go into one called Freddy Frog now, you will need to put double quotes around it to make sure the space between Freddy and Frog is kept and it doesn't think you want to go to a folder called Freddy then one called Frog. so type
cd "Freddy Frog"
ls
and you can now go to the "Spiders from Mars" directory in there with
cd "Spiders from Mars"
ls
In general, you can just start typing the name of the folder you mean and press TAB and it will guess what you mean. So, if you start a new Terminal and type:
ls
you will see the files in your Home directory. Now type:
cd Desk<TAB>
and it will show you what it guesses you mean. That's called filename completion. If you want to know where you are currently located, use:
pwd
which will print the working directory.
If you want to return to your HOME directory at any time, just type:
cd
Two other tips for you if you are learning your way around...
Firstly, if you want Finder to open and display the directory you are currently in in the Terminal, you can run:
open .
Secondly, when Finder opens, you can turn on the Path bar at the bottom of the window by typing:
Command+Option+P
I have shown it in red - no idea why Apple ships with it turned off by default - probably explains why most Mac users I have met generally have no idea where their files are and don't know the difference between copying and moving files!

To change directory to say /usr , the command should be cd /usr
i.e. cd followed by the absolute path of the directory. For relative paths use cd ./usr where the directory usr is in your current directory.This link gives complete documentation of cd command.

Use the change directory command:
using relative paths cd ./relative/path/to/directory
using absolute paths cd /absolute/path/to/directory
IMPORTANT: do not to forget the space after cd and before the path!!!!!
On Windows, the space isn't needed for some reason...

Related

Should I use the first and/or last slash in commands in bash? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 2 years ago.
Improve this question
What is the canonical way of using trailing and first slashes in Linux OS?
Which of these commands are the most canonical and preferred and unambiguous one should use in tutorials and script that are public?:
Let's say we want to tell the reader of our article to go into the "etc" folder in Ubuntu. What should we write as the command?
Here are the options I can think of:
cd etc
cd /etc
cd etc/
cd /etc/
So, which one is the less ambiguous and preferred way of telling that to our readers?
Not sure if there is a canonical version, but these are different commands:
cd etc <-- change directory to 'etc' only if 'etc' exists in the current working directory
cd /etc <-- change directory to the 'etc' directory in the root of the file system
cd etc/ <-- same as item 1. The trailing forward-slash makes it clear that this is a directory, but this isn't necessary since the 'cd' command provides ample context
cd /etc/ <-- same as item 2. The trailing forward-slash makes it clear that this is a directory, but this isn't necessary since the 'cd' command and leading forward slash provide ample context
As far as the trailing forward-slash goes, I don't think it's necessary unless you need to indicate that something is a directory when it's otherwise unclear. In most cases it's not necessary and looks awkward. As long as you're communicating what a command is/does, extra details aren't necessary.
Read documentation of GNU bash and download then study its source code (since it is free software), syscalls(2), chdir(2), path_resolution(7), credentials(7).
cd etc or cd etc/ are changing the current directory (of your bash process) to the etc directory in the current working directory.
cd /etc or cd /etc/ are changing the current directory (of your shell) to the /etc directory in the root directory . See inode(7), the stat(1) and ls(1) commands, the stat(2) system call.
You could prefer in your documentation, for readability, cd /etc/ or cd etc/ to remind your reader that /etc/ is an existing directory.
Notice the existence of the chroot(2) system call (used by the chroot(1) command) which could change the root directory (of your shell process). It is unusual to do so, and that system call can fail (like many others, see errno(3)...). In rare cases, you would use the chroot(1) command.
Also, consider changing your shell with the chsh(1) command. I prefer zsh (see file /etc/shells documented in shells(5)). You could try the es shell.

How to change default directory in Bash for Windows 10? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 5 years ago.
Improve this question
How can I change the default directory of windows bash to a folder of my choosing?
EDIT: I guess I should have been more clear. When I startup Bash I want it the directory to be in a location of my choosing like Desktop or something. How do I go about setting a default directory?
If you want change the directory your bash prompt is starting in, you can edit your .bashrc file. At the bottom, add:
cd ~
This will go into your home directory. (you can actually do just cd, but I it's clearer to add the ~ IMO)
To edit, you can use vim. If you don't know how to use it, you can always use nano for the time being, but you really should have a look at it, it's really powerful.
$ nano ~/.bashrc
This will open nano in "full console". At the bottom, you have the few commands you can use (^ means control) Do your changes, hit ctrl+o to save the file (write the file). It'll ask you where to write, by default, it's the right location, just hit enter and the .bashrc file will be saved. Then, you can press ctrl+x to exit.
Steps to set default directory for Bash on Ubuntu on Windows to a folder -
Open Bash on Ubuntu on Windows.
cd ~ to go to home directory of Ubuntu
Type edit .bashrc and enter at the Bash. This will open the file in vim.
Use Down Arrow or Page Down key on keyboard to go to the end of the file (there's a helpful progress bar at the bottom right corner of the Bash). At the end of this file, you will find cd ~, replace cd ~ with your desired location.
Save the .bashrc file. To save the file, click esc and then type :wq and click enter.
Note:
To access your hard disk location make sure you include the mount directory first.
So if want your Bash to open at C:\dev whenever you open the Bash. You need to replace the cd ~ with cd /mnt/c/dev at .bashrc file at Ubuntu home directory.
Just enter echo "cd ~" >> ~/.bashrc. This will append "cd ~" to your .bashrc.
.bashrc is executed everytime you start a(n interactive) bash instance.

browse /tmp in Finder? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 2 years ago.
Improve this question
I wish to go to a specific folder, and I am trying "the menu Go -> Go to folder and enter the path of the folder " as this thread
(https://apple.stackexchange.com/questions/32377/how-do-i-browse-tmp-in-finder) suggested.
However, cannot find the folder.
The folder I am trying to enter is simply the "tmp" folder from the root folder.
I also tried "browser (chrome, firefox), and in the URL bar file:///tmp/", but it gives a different folder compared to the folder that terminal gives.
Did I missed something ? Thanks
PS: from terminal the folder can be found. I only need to enter the folder from the menu for some reason (I need enter a sub-folder named "tensorflow_logs" which is inside "tmp" folder).
You have 3 ways of getting your job done:
In a terminal, type open /tmp
In the Finder, "Go to folder" -> /tmp
In the folder, from the root of the file system, "Go to folder" -> tmp.
Note the similarity between the "Go to folder" and bash when it comes to resolving absolute and relative paths. For the latter, you have to change the "working directory" before.
In UNIX, and OSX is a UNIX flavor, there are path naming conventions which haven't changed for 40 years.
Terms 'Folder' and 'Directory' are interchangeable in OSX.
File system is like a tree,folders in the path hierarchy are delimited by the / sign (in English: slash)
There are two types of path: relative and absolute
Relative paths, observed from current folder, start with name of the next subfolder, i.e. tmp (no / at the beginning).
Asolute paths, observed from the system root folder always start with /, i.e. (/tmp) in your case.
Therefore, you can reach the desired folder by typing its relative path tmp only if you are already in the root folder. From your home or desktop folder it can't be found. So it's better to use absolute path when trying to reach some of those "system owned" folders.
In OSX, some folders reserved for system functionality are invisible from Finder, in order not to confuse the casual user and keep it fool-proof.

Find string within hidden file on OS X [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 8 years ago.
Improve this question
I am trying to find text within one of bash's setup files on my mac (10.9.2).
I know the text "PIP_RESPECT" is in .bash_profile
I tried Find Any File, which apparently does not search within files.
I rebuilt my spotlight index.
I tried a finder search with visibility set to invisible, with no luck
I tried the following terminal commands:
mdfind "PIP_RESPECT"
mdfind *PIP_RESPECT*
mdfind "*PIP_RESPECT*"
mdfind '"*PIP_RESPECT*"'
which return nothing.
mdfind 'kMDItemTextContent == "*PIP_RESPECT*"cd'
which returns:
~/Library/Application Support/Firefox/Profiles/6wjt9c4s.default/sessionstore.js
which is clearly not the .bash_profile.
So what am I doing wrong?
Thank you for all your responses:
I am just trying to find the text "VIRTUALENVWRAPPER_PYTHON," if it exists, in any file, by any means.
I listed all the things I tried.
# stakolee:
$ grep 'PIP_RESPECT' ~/.bash_profile return in the terminal
returned:
~/.bash_profile:export PIP_RESPECT_VIRTUALENV=true
grep: return: No such file or directory
grep: in: No such file or directory
grep: the: No such file or directory
grep: terminal: No such file or directory
so the top return is what I want, thank you. I would give you a check mark, but it does not seem to allow check marks in comments.
#Mark Setchell
Easy Find finished a lot faster, but you have made me realize I need to learn more about grep.
I awarded the checkmark to:
# Thomas Tempelmann "find any file guy": sorry, I didn't mean to dis your app, but the Easy Find app did work, after i changed the settings to scan all files
I clearly have more to learn, thank you all, again.
I am not sure from your question if you are trying to say "How do I make Spotlight find a file?" or "I want to find a file containing PIP_RESPECT and I don't care how".
If the second, you can search through every file on your Mac from the terminal like this:
sudo find / -type f -exec grep PIP_RESPECT {} /dev/null \; 2> /dev/null
It will take some time to run! It says... starting at the root (top) of the filesystem, find everything that is a file (not directory) and look in every file (with grep) and see if you can find PIP_RESPECT and print the name of the file if you can and throw away error messages.
If you only want to search in your own login directory and below, it will be quicker and easier to do this (thanks to #I'L'I):
find ~ -type f -exec ....
Author of Find Any File here.
I tried Find Any File, which apparently does not search within files.
Right, it doesn't. But it documents that clearly both on the web page. May I quote:
Contrary to Spotlight, [...], but not for file content (use Spotlight or EasyFind for that).
And if you read a bit further down:
Alternatives to Find Any File
If you like to search for data inside files, and Spotlight doesn't do it for you, have a look at EasyFind by DEVONtechnologies [...]
If you want to search for specific text in a large set of files inside a directory, I recommend TextWrangler.
Also, the reason why Spotlight (including mdfind) doesn't find anything is that Spotlight implicitly ignores anything in the System folders. It won't ever find anything in there.
Hope that helps.

How to stop creating .DS_Store on Mac? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 7 years ago.
Improve this question
I'm developing sites on mac and every time I create some folder (or file in that folder) .DS_Store is created in that folder.
How to prevent creating .DS_Store file ?
Please install http://asepsis.binaryage.com/ and then reboot your mac.
ASEPSIS redirect all .DS_Store on your mac to /usr/local/.dscage
After that, You could recursively delete all .DS_Store from your Mac.
find ~ -name ".DS_Store" -delete
or
find <your path> -name ".DS_Store" -delete
You should repeat procedure after each major Mac update.
NOTE: "Asepsis is no longer under active development and supported under OS X 10.11 (El Capitan) and later."
Here's a comprehensive review of your options. Asepsis (the second solution mentioned) seems to be what you're looking for, it re-routes .DS_Store creation to a unified cache instead of being located on every folder.
Its is possible by using mach_inject. Take a look at Death to .DS_Store
I found that overriding HFSPlusPropertyStore::FlushChanges() with a
function that simply did nothing, successfully prevented the creation
of .DS_Store files on both Snow Leopard and Lion.
DeathToDSStore source code
NOTE: On 10.11 you can not inject code into system apps.
Open Terminal. Execute this command:
defaults write com.apple.desktopservices DSDontWriteNetworkStores true
Either restart the computer or log out and back in to the user account.
for more informations:
https://support.apple.com/en-us/HT208209
Put following line into your ".profile" file.
Open .profile file and copy this line
find ~/ -name '.DS_Store' -delete
When you open terminal window it will automatically delete your .DS_Store file for you.
this file starts to appear when you choose the system shows you the hidden files: $defaults write com.apple.finder AppleShowAllFiles TRUE
If you run this command disapear
$defaults write com.apple.finder AppleShowAllFiles FALSE
Use terminal
the function
find ~/ -name '.DS_Store' -delete
, removed the .DS store files temporarily. But am not sure , whether the files will came back on the Mac.
Also i noticed something peculiar, the "DS_Store" start coming to the Mac after installing 'ATOM'. So guys please make it sure to scan properly your third party software before installing them.
Best
If you want the .DS_Store files to become invisible (they still exist but can't be seen) then run the following command in the "Terminal" window:
defaults write com.apple.finder AppleShowAllFiles FALSE; killall Finder
This will set the system default to stop showing these files on your Desktop and elsewhere. It will also restart the Finder in order to make this change visible (especially on your Desktop).

Resources