08.08.2020»»суббота

Terminal Command For Selecting Current User Macos

08.08.2020
Terminal Command For Selecting Current User Macos Average ratng: 6,3/10 7438 votes

Mar 21, 2018 How to open Terminal on Mac. The Terminal app is in the Utilities folder in Applications. To open it, either open your Applications folder, then open Utilities and double-click on Terminal, or press Command - spacebar to launch Spotlight and type 'Terminal,' then double-click the search result.

When you run any command in the OS X Terminal, you are running some program that has been coded and compiled to perform a specific function, be it something simple like “ls” to list directory contents, or something more interactive like “top” to display information on running processes. These commands are all programs on your Mac, just like applications such as Pages, Word, TextEdit, and Safari that have graphical interfaces and are the main productivity programs you use when running OS X.

Opening Applications using the Terminal

Most applications in OS X are opened by using a graphical approach like mouse click actions or services like Spotlight; however, you can also open applications using the OS X Terminal. This might seem unnecessary, but it can have its uses. For instance, I have a Mac Mini running the third-party media center software “XBMC” on it. This software sometimes crashes and needs to be relaunched, so while I can screen share to it or rummage for my wireless mouse and keyboard to access it, another approach if I am at my laptop is to simply log in with SSH and use one of several command options for opening the program.

1. Direct executable execution

Applications in OS X are packaged as bundles, which are folders including the executable along with any supporting resources (libraries, images, fonts, etc.) that the program needs to run. You can see these by right-clicking any application and choosing the option to “Show Package Contents.” In this bundle structure, the application executable is located in the /Contents/MacOS/ directory, and can be launched directly in the Terminal by specifying the full path to this executable. For example, you can open Safari by running the following command:

Wait until you see the text Copy Complete. (see the screenshot above), which could take as long as 20 or 30 minutes, depending on how fast your Mac can copy data to your destination drive.You now have a bootable Yosemite install drive. Flash for os x yosemite national park. The program then tells you it’s copying the installer files, making the disk bootable, and copying boot files. If you like, you can rename the drive from its default name of Install OS X Yosemite, though I think it’s kind of a catchy name.

While this will open the specified program, this method has some limitations and restrictions that might cause problems. For one, the program will be launched as a child process of the current Terminal window, so if you close the Terminal window you will close the program. In addition, such behaviors might interfere with Apple’s Resume service and not save any of your open windows for the next time you re-launch your program.

2. The “open” command

My preferred method of opening an application from the Terminal is to use the “open” command with the the “-a” flag to specify the application by name. For example, the following command will open Safari:

This approach mimics opening the program using the graphical interface, and can be useful if you are creating scripts where you would like to open a specific application. You can also use many of the “open” command’s options to do things like launch a new instance of a program (though this may conflict with OS X’s Resume service), or open a program in the background. In addition, since the “open” command launches applications indirectly, once run you can simply close the Terminal window and the application will remain open, as opposed to using direct executable execution.

The “open” command is also useful because you can cleanly launch applications for the current user account on a remote system. For instance, in looking at the XBMC setup on my Mac Mini, when XBMC crashes I can use “ssh” to remotely log in as the current username and then simply run “open -a XBMC” to quickly re-launch it.

3. Osascript approaches

The “osascript” command is OS X’s Terminal command for running “open scripting architecture” scripts like AppleScript. Since with AppleScript you can instruct the system to do things like launch applications, with a relatively basic scripting line like ‘open app “APPNAME”‘ coupled with the “osascript” command, you can create a quick one-line command to open any application on the system. For example, the following command will launch Safari similar to the “open” command above:

Keep in mind that as with the “open” command, this will also require you to be logged into the system as the currently active user. Otherwise you will get an error (-10810) at the Terminal and the specified application will not open.

Quitting Applications using the Terminal

While the “open” command is great for launching applications, this approach will only open them and does not provide a way to quit them. Therefore, the AppleScript approach with the “osascript” command may be the easiest way to cleanly quit a running application using the Terminal. For example, given the command above to open Safari, you can use the following one to easily quit it:

Note that while this will attempt to quit programs, if you have unsaved changes in them and a Save dialogue box or other notice pops up that requires user input to proceed, then the program will not quit.

Force-quitting Applications using the Terminal

Terminal Command For Selecting Current User Macos Download

If you need to force-quit an application using the Terminal, then this can be done in two ways. The first is to simply use the “killall” command, which allows you to specify a program by name and then the system will internally identify it and close it down. The following command is a way to force-quit Safari (since we’ve been using this as an example so far):

In addition to this, for those who like to delve a little deeper into the Terminal, you can first find the process ID (PID) of the running application and then use the standard “kill” command to force-quit it. There are several ways to get the PID of a running application, but an easy one in the Terminal is to use the “pgrep” command and specify the program name. For example, to do so with Safari you would run the following command:

If Safari is running, then this command will output a single number that is the program’s PID. You can then use “kill PID” (replacing PID with the number) to quit Safari. This approach is a two-step process, but you can lump it all into one command by nesting them together using grave accent symbols to encase the “pgrep” command, such as the following:

What these accent symbols do is first execute the “pgrep Safari” command, and then use the result when running the “kill” command. Therefore, this essentially finds the PID for Safari, and then kills the specified PID.

Hidden behind beautiful Mac screens is the world of Terminal Command lines. Knowing how to use these commands will help you increase your work efficiency in a great way.

17 rows  May 26, 2020  If your Mac is using an earlier version of any Mac operating system, you. Mid 2010 imac latest os. Easily check which versions of mac OS, iOS, iPadOS, or watchOS are compatible with your Mac model or iDevice. Guide includes OS X 10.8.x to macOS 11.0.x.

Below is a list of the most basic commands divided by purpose of use:

Macos Terminal Admin

CORE COMMANDS

Key/CommandDescription
cd [folder]Change directory e.g. cd Documents
cdHome directory
cd ~Home directory
cd /Root of drive
cd –Previous directory
lsShort listing
ls -lLong listing
ls -aListing incl. hidden files
ls -lhLong listing with Human readable file sizes
ls -REntire content of folder recursively
sudo [command]Run command with the security privileges of the superuser (Super User DO)
open [file]Opens a file ( as if you double clicked it )
topDisplays active processes. Press q to quit
nano [file]Opens the file using the nano editor
vim [file]Opens the file using the vim editor
clearClears the screen
resetResets the terminal display
Terminal command for selecting current user macos windows 7

CHAINING COMMANDS

Key/CommandDescription
[command-a]; [command-b]Run command A and then B, regardless of success of A
[command-a] && [command-b]Run command B if A succeeded
[command-a] [command-b]Run command B if A failed
[command-a] &Run command A in background

PIPING COMMANDS

Key/CommandDescription
[command-a] [command-b]Run command A and then pass the result to command B e.g ps auxwww grep google

COMMAND HISTORY

Key/CommandDescription
history nShows the stuff typed – add a number to limit the last n items
Ctrl + rInteractively search through previously typed commands
![value]Execute the last command typed that starts with ‘value’
![value]:pPrint to the console the last command typed that starts with ‘value’
!!Execute the last command typed
!!:pPrint to the console the last command typed

Macos Terminal App

FILE MANAGEMENT

Key/CommandDescription
touch [file]Create a new file
pwdFull path to working directory
.Current folder, e.g. ls .
.Parent/enclosing directory, e.g. ls .
ls -l .Long listing of parent directory
cd ././Move 2 levels up
catConcatenate to screen
rm [file]Remove a file, e.g. rm data.tmp
rm -i [file]Remove with confirmation
rm -r [dir]Remove a directory and contents
rm -f [file]Force removal without confirmation
cp [file] [newfile]Copy file to file
cp [file] [dir]Copy file to directory
mv [file] [new filename]Move/Rename, e.g. mv file1.ad /tmp
pbcopy < [file]Copies file contents to clipboard
pbpastePaste clipboard contents
pbpaste > [file]Paste clipboard contents into file, pbpaste > paste-test.txt

DIRECTORY MANAGEMENT

Key/CommandDescription
mkdir [dir]Create new directory
mkdir -p [dir]/[dir]Create nested directories
rmdir [dir]Remove directory ( only operates on empty directories )
rm -R [dir]Remove directory and contents
less [file]Output file content delivered in screensize chunks
[command] > [file]Push output to file, keep in mind it will get overwritten
[command] >> [file]Append output to existing file
[command] < [file]Tell command to read content from a file

SEARCH

Key/CommandDescription
find [dir] -name [search_pattern]Search for files, e.g. find /Users -name 'file.txt'
grep [search_pattern] [file]Search for all lines that contain the pattern, e.g. grep 'Tom' file.txt
grep -r [search_pattern] [dir]Recursively search in all files in specified directory for all lines that contain the pattern
grep -v [search_pattern] [file]Search for all lines that do NOT contain the pattern
grep -i [search_pattern] [file]Search for all lines that contain the case-insensitive pattern
mdfind [search_pattern]Spotlight search for files (names, content, other metadata), e.g. mdfind skateboard
mdfind -onlyin [dir] -name [pattern]Spotlight search for files named like pattern in the given directory

HELP

Key/CommandDescription
[command] -hOffers help
[command] –helpOffers help
info [command]Offers help
man [command]Show the help manual for [command]
whatis [command]Gives a one-line description of [command]
apropos [search-pattern]Searches for command with keywords in description