- Открытие и завершение приложения «Терминал» на Mac
- Открытие Терминала
- Завершение приложения «Терминал»
- Завершение сеанса shell
- How to create a bootable installer for macOS
- What you need to create a bootable installer
- Download macOS
- Use the ‘createinstallmedia’ command in Terminal
- Use environment variables in Terminal on Mac
- Как обновить Mac OS X через Terminal
- Как найти обновления для Mac через Терминал
- Как установить обновления для Mac OS X с помощью Terminal
- Is there a Mac OS X Terminal version of the «free» command in Linux systems?
- 21 Answers 21
- Bash commands «free like» for Mac OSX.
Открытие и завершение приложения «Терминал» на Mac
Каждое окно в Терминале представляет свой экземпляр процесса shell. Окно содержит приглашение, которое означает, что можно вводить команду. Отображаемое приглашение зависит от настроек Терминала и shell, однако обычно оно включает имя хоста, к которому Вы подключены, Вашу текущую рабочую папку, Ваше имя пользователя и символ приглашения. Например, если пользователь с именем michael использует по умолчанию оболочку zsh, приглашение выглядит следующим образом:
В приглашении указано, что пользователь с именем michael вошел в систему на компьютере с именем MacBook-Pro и текущей папкой является его папка пользователя, обозначаемая тильдой (
Открытие Терминала
На компьютере Mac выполните одно из следующих действий.
Нажмите значок Launchpad в панели Dock, введите «Терминал» в поле поиска и нажмите значок Терминала.
В окне Finder откройте папку «Программы/Утилиты» и дважды нажмите приложение «Терминал».
Завершение приложения «Терминал»
В приложении «Терминал» на Mac выберите пункт меню «Терминал» > «Завершить Терминал».
Завершение сеанса shell
В окне приложения «Терминал» на Mac, где запущен процесс shell, который Вы хотите завершить, введите exit и нажмите клавишу Return.
Это обеспечит закрытие всех текущих команд, выполняемых в shell. Если что-то продолжает выполняться, появляется диалоговое окно.
Если Вы хотите изменить поведение при выходе из shell, см. Изменение настроек shell для профилей.
Источник
How to create a bootable installer for macOS
You can use an external drive or secondary volume as a startup disk from which to install the Mac operating system.
These advanced steps are primarily for system administrators and others who are familiar with the command line. You don’t need a bootable installer to upgrade macOS or reinstall macOS, but it can be useful when you want to install on multiple computers without downloading the installer each time.
What you need to create a bootable installer
- A USB flash drive or other secondary volume formatted as Mac OS Extended, with at least 14GB of available storage
- A downloaded installer for macOS Big Sur, Catalina, Mojave, High Sierra, or El Capitan
Download macOS
- Download: macOS Big Sur, macOS Catalina, macOS Mojave, or macOS High Sierra
These download to your Applications folder as an app named Install macOS [ version name ]. If the installer opens after downloading, quit it without continuing installation. To get the correct installer, download from a Mac that is using macOS Sierra 10.12.5 or later, or El Capitan 10.11.6. Enterprise administrators, please download from Apple, not a locally hosted software-update server. - Download: OS X El Capitan
This downloads as a disk image named InstallMacOSX.dmg. On a Mac that is compatible with El Capitan, open the disk image and run the installer within, named InstallMacOSX.pkg. It installs an app named Install OS X El Capitan into your Applications folder. You will create the bootable installer from this app, not from the disk image or .pkg installer.
Use the ‘createinstallmedia’ command in Terminal
- Connect the USB flash drive or other volume that you’re using for the bootable installer.
- Open Terminal, which is in the Utilities folder of your Applications folder.
- Type or paste one of the following commands in Terminal. These assume that the installer is in your Applications folder, and MyVolume is the name of the USB flash drive or other volume you’re using. If it has a different name, replace MyVolume in these commands with the name of your volume.
Big Sur:*
Catalina:*
Mojave:*
High Sierra:*
El Capitan:
* If your Mac is using macOS Sierra or earlier, include the —applicationpath argument and installer path, similar to the way this is done in the command for El Capitan.
After typing the command:
- Press Return to enter the command.
- When prompted, type your administrator password and press Return again. Terminal doesn’t show any characters as you type your password.
- When prompted, type Y to confirm that you want to erase the volume, then press Return. Terminal shows the progress as the volume is erased.
- After the volume is erased, you may see an alert that Terminal would like to access files on a removable volume. Click OK to allow the copy to proceed.
- When Terminal says that it’s done, the volume will have the same name as the installer you downloaded, such as Install macOS Big Sur. You can now quit Terminal and eject the volume.
Источник
Use environment variables in Terminal on Mac
The shell uses environment variables to store information, such as the name of the current user, the name of the host computer and the default paths to any commands. Environment variables are inherited by all commands executed in the shell’s context and some commands depend on environment variables.
You can create environment variables and use them to control the behaviour of a command without modifying the command itself. For example, you can use an environment variable to have a command print debug information to the console.
To set the value of an environment variable, use the appropriate shell command to associate a variable name with a value. For example, to set the variable PATH to the value /bin:/sbin:/user/bin:/user/sbin:/system/Library/ , you would enter the following command in a Terminal window:
To view all environment variables, enter:
When you launch an app from a shell, the app inherits much of the shell’s environment, including exported environment variables. This form of inheritance can be a useful way to configure the app dynamically. For example, your app can check for the presence (or value) of an environment variable and change its behaviour accordingly.
Different shells support different semantics for exporting environment variables. See your preferred shell’s man page.
Although child processes of a shell inherit the environment of that shell, shells are separate execution contexts that don’t share environment information with each other. Variables you set in one Terminal window aren’t set in other Terminal windows.
After you close a Terminal window, variables you set in that window are no longer available. If you want the value of a variable to persist across sessions and in all Terminal windows, you must set it in a shell startup script. For information about modifying your zsh shell startup script to keep variables and other settings across multiple sessions, see the “Invocation” section of the zsh man page.
Источник
Как обновить Mac OS X через Terminal
Приложение Terminal служит для работы с командной строкой в Mac OS X. С его помощью можно искать и устанавливать обновления системы. Как это сделать, расскажем в данной статье.
Чтобы операционная система для вашего Mac всегда была актуальна, необходимо регулярно устанавливать обновления. Апгреды для Mac OS X можно найти с помощью приложения Terminal.
Как найти обновления для Mac через Терминал
Чтобы начать работу с приложением Terminal:
- Откройте меню «Программы» — «Служебные программы» — «Terminal.app» или задайте в окне поиска Spotlight слово «Terminal».
- Для просмотра доступных обновлений введите в командной строке «sudo softwareupdate -l» или «sudo softwareupdate -list» и нажмите Enter.
- Введите ваш пароль. Для отображения результатов может понадобиться некоторое время — это зависит от количества доступных обновлений.
Как установить обновления для Mac OS X с помощью Terminal
Чтобы установить все доступные обновления, надо ввести в командной строке «sudo softwareupdate -i -a» и подтвердить ввод нажатием на Еnter. Система может потребовать пароль еще раз.
Чтобы активировать не все, а только рекомендуемые обновления, используйте команду «sudo softwareupdate -i -r». При необходимости снова введите пароль и дождитесь завершения установки.
Источник
Is there a Mac OS X Terminal version of the «free» command in Linux systems?
On Linux, I often use the free command to see the current amount of free and used memory in the system. For example:
It does not seem to exist when I enter free in Mac OS X’s Terminal. Is there an alternative?
21 Answers 21
As @khedron says, you can see this info in Activity Monitor.
If you want it on the command line, here is a Python script that I wrote (or perhaps modified from someone else’s, I can’t remember, it’s quite old now) to show you the Wired, Active, Inactive and Free memory amounts:
As you can see, you can just call vm_stat from the command line, though it counts in 4kB pages, hence the script to convert to MB.
The script also counts up the «real memory» usage of all running processes for comparison (this won’t match any specific value(s) from overall memory stats, because memory is a complex beast).
Here’s an example of the output of the script on my system:
(very slightly adjusted to match the tab sizing on StackExchange 😉
The command you need is vm_stat — similar to the traditional Unix tool vmstat but with a few MACH-specific differences. The man page is well written.
It seems the reason it’s slow is because top -l 1 always delays by one second after completing, the standard delay between refreshes. Adding -s 0 to the command makes it complete instantly:
Also, for clarity, I like showing each mem-component on its line, so I added 9 spaces for alignment with ‘PhysMem: ‘ in the sed replacement string:
Here’s a simple one-liner to make the whole vm_stat output more human friendly:
In case you’re only really interested in swap usage (what would be the last line of output from free ):
There is a terminal command similar to free on Mac OS X. it is called top
For further information you can check out this Apple Support document.
Just taking the solution from @zack and adding inactive and speculative blocks.
You can try the memory_pressure command. See the output of my system (i5, 4 GB RAM)
There’s no exact equivalent that’s distributed with Mac OS X, but there are a couple other ways to get the information:
- system_profiler — Shows all of the Mac’s System Profile info in the shell
- sysctl -a | grep mem or sysctl hw.memsize (total mem)
For Unix experts only:
Judging by your other question, I think you’ve found the use of the Activity Monitor utility to look at your memory status, right? Just for the record, it’s in /Applications/Utilities/Activity Monitor.app.
You might try the command allmemory if you want a command line tool that reports extremely detailed memory usage.
The above is way too much effort for my liking, and it assumes that you have a fully fledged install too. If you’ve booted from a Mac OS X start up disk, then all the above solutions obviously won’t work. Just use the command «hostinfo», here’s the output from my mid 2012 MBAir running Mavericks (10.9.1):
The good this about this command is that it comes preinstalled with the 10.9 installer too under /usr/bin , so it’s very handy,
ideally, if you just want RAM then issue:
Don’t know if hostinfo exists on any previous OSes though.
This should do nicely 🙂
I think these days, psutil and its meminfo.py script provide the most helpful memory-usage details. To try it:
The output it produces looks like this:
Notice the Available row, which shows an estimate of how much memory is actually available for starting new applications, without swapping.
I don’t know of any other MacOS utility providing that available-memory estimate.
For the sake of comparison: On a Linux system, the same sort of information is provided in the available column in output from current versions of free :
That available column in free output just comes from MemAvailable in /proc/meminfo . And on systems that have /proc/meminfo , psutil also just uses that to estimate available memory.
But MacOS doesn’t have /proc/meminfo , so to estimate the available memory in that case, psutil employs the same algorithm used on Linux to calculate MemAvailable for /proc/meminfo .
Bash commands «free like» for Mac OSX.
This is the second reissue of this post. At first, I got two -1 . One because I was not describing in English, it is corrected. The other because I used gawk (which is not part of a standard OS X installation), it is also corrected, I now use awk . The -2 are still there ;-). The best is perhaps now to test and evaluate the commands it themselves?
I reviewed my first idea to build only one end-user oriented command with a friendly and highly configurable display, I made two:
free-like.sh a script always oriented «end user», with more accuracy, a «friendly» and configurable display, but with more calculations and resource consumption,
free-like-raw.sh , a command now oriented developer, sysadmin, etc. with less computation and resource consumption, but also with less precision, less «friendly» display.
The data for the physical memory are extracted from the results of the command vm_stat (which returns the results in blocksize). The imprecision resulting from the transformation in bytes (number_of_blocks * block_size, the default value of the calculations) will be between 0 top command. The imprecision here is linked to the unit of reference of the top command: kilo, mega, giga.
Calculations are made using awk that respects rounded (as opposed to bc ). awk is also quicker than bc . You can see the test script here: http://myblog.robert.sebille.name/article29.html#awk-bc
You can view the results of the commands in bytes (default), in kilo, mega or giga, with x decimal places in the case of free-like.sh and if you ask the display in mega ou giga.
The scripts are too long for a post, but you can find them on this article of my blog: http://myblog.robert.sebille.name/article29.html
The article is in french, but it display one example of display for each command and their integrated help ( ./free-like.sh -h and ./free-like-raw.sh -h ), in english. These aids completely describe the commands. The article display also the codes.
English is not my mother language. If somebody wants to correct errors in the integrated help, he is welcome ;).
Источник