Hey
Terminal
Terminal, the wonder app, can do pretty much anything. This post is going to show you how you can unzip files using Terminal. I will also show you how you can can combine commands to download and unzip files really quickly. Its really simple to complete. You may want to use Terminal since you can access extra options which you may normally be hidden away from you.
The first step is to open Terminal. Use the “cd” command to change the directory to the location where you want to unzip the zip file. For example you can use:
cd ./Desktop
Make a file executable. Script management with launchd. Automate tasks using AppleScript and Terminal. Keyboard shortcuts. Open or quit Terminal on Mac. Each window in Terminal represents an instance of a shell process. The window contains a prompt that indicates you can enter a command. In the Terminal app on your Mac, in the window. Use similar commands specifying the application location and name followed by “.app” to open any application on your Mac. Open Folder in Terminal. Conversely, if you are in a folder in Finder and want to open it in Terminal, you can easily add a right-click shortcut to do so. Related: How to Add Options to macOS’s Services Menu.
The next step is to invoke the unzip command. Type the following into Terminal. This assumes you have a zip file ready to unzip.
unzip file.zip
This will unzip you file into you desktop location. If you want to change this location you can type the following.
unzip file.zip -d ~/another/folder
You can also remove all of the text that Terminal will output when you run the command by adding a modifier/option to the front of the syntax.
unzip -q file.zip
Optionally you can also add more information by adding a verbose option. This will show you all of the details of the file you unzip.
unzip -v file.zip
You can combine this command with other command so you can download and unzip a file automatically. For example if you have wget installed you can type in Terminal.
Watercolor apps for mac.
cd ~/download;wget http://www.example.com/file/zip;unzip file.zip
The different commands are separated by a semi-colon (;). The previous command will change your directory to your downloads folder. It will then grab the zip file from your website and unzip the file to your location.
The one problem with unzip command is that it creates a an extra folder called “__MACOSX” this folder would normally be hidden as it stores extra data that you don’t need to see. You can easily get rid of this by combining the delete command with the unzip command.
unzip file.zip;rm -rf __MACOSX
That will unzip the file and then delete this extra folder. You can of course combine this with the download command previously.
You could even take this further by moving files and folders although that would be out of the scope of this article. How quick do you reckon it would be to type that command compared to downloading a zip folder normally and then normally extracting it. You do have to type more, but it is a lot less clicking and searching in Finder.
If you want to take your skills with Terminal a bit further I recommend you check out the Terminal Category on this site. If you fancy reading a book there is a couple on Amazon that I regularly see mentioned and recommend, O’reilly Unix Geeks and Unix Under the Hood both are designed for Mac OS X and take Terminal further.
If you want to keep up with the latests post from Mac Tricks And Tips I recommend you subscribe to the RSS Feed.
Related posts:Where To Next?
Make things happen quickly without touching the mouse
![]()
This tutorial describes how to make use of the macOS Terminal to make your life easier and less frustrating.
What Apple calls the Terminal is what Linux people call the shell console (more specifically, the Bash shell). It’s also called a command-line terminal, abbreviated as CLI.
Information here is often used in interview questions.
Open Terminal (several ways)
On the Mac, the Terminal app is kinda buried, probably perhaps because those who use a MacOS laptop just for social media probably won’t need a Terminal.
But if you’re a developer, it’s hard to get away from using a CLI.
There are different ways to open a Terminal command line.
My preferrence is a way that doesn’t require reaching for a mouse and using the least number of keystrokes:
Alternately, if you prefer moving your mouse:
PROTIP: If you are at the Finder program (since Yosemite) you can open a Terminal to a folder listed within Finder by pointing your mouse on it, then tapping with two fingers on the touchpad/mousepad.To enable that:
Bash shell invocations
I put in an echo in the various files that macOS executes upon user login, when a new terminal is opened, and when a bash shell is invoked:
When macOS logs in a user, it executes file /etc/profile. That file’s code:
echo ${BASH-no} resolves to /usr/local/bin/bash.
The /etc/bashrc file contains:
The above defines the $PS1 variable which sets the Terminal’s prompt to the left of the cursor.
NOTE: On Ubuntu, instead of /etc/bashrc, the file is /etc/bash.bashrc.
RedHat also executes /etc/profile.d if the shell invoked is an “Interactive Shell” (aka Login Shell) where a user can interact with the shell, i.e. your Terminal bash prompt.
Thus, whatever is specified in /etc/profile is NOT invoked for “non-interactive” shells invoked when a user cannot manually interact with it, i.e. a Bash script execution.
PROTIP: One can change those files, but since operating system version upgrades can replace them without notice, it’s better to create a file that is not supplied by the vendor, and within each user’s $HOME folder: ~/.bash_profile
In other words, file /etc/profile is the system wide version of ~/.bash_profile for all users.
Examples of custom settings include:
export HISTSIZE=1000 # sets the size of .bash_history lines of command history (500 by default)
User Mask for permissions
Wikipedia says umask controls how file permissions are set for newly created files. Please read it for the whole story on this.
Within Text Editors/IDEs
Many prefer the terminals built into VS Code and other editors/IDEs.
Text wrapping
This page contains notes for system administrators and developers,who need to control Macs below the UI level, which requiretyping commands into a command-line terminal screen.
Hyper terminal app
Get the .dmg installer from the websitehttps://hyper.is. It’s used by tutorials author Wes Bos.
Unlike Apple’s Terminal, which is closed-source, Hyper is an open-source and extensible terminal emulator. It is available on MacOS, Windows, and Linux because it’s built using Electron (the same platform that powers Atom, Slack, and Brave). So it can be slow.
To customize Hyper, add the name of many packages to its config file ~/.hyper.js. Build an extension based on hyper.is/#extensions-api.
iTerm2 for split pane
Many prefer to install and use iTerm2 instead of the built-in Terminal program.Install iTerm2 using Homebrew:
Terminal does not support but iTerm2 does support dividing the CLI into several rectangular “panes”, each of which is a different terminal session:
Pressing the shortcut again restores the hidden panes.
On Linux, there is the
screen command.
See Iterm2 Cheat Sheet of iTerm2 keyboard shortcuts. https://github.com/nobitagit/iterm-cheat-sheet/blob/master/README.md
Alphabetical Commands list
A list of all commands native to macOS is listed alphabetically at https://ss64.com/osx.
Exit
To exit from the Terminal shell:
exit
Get back in for the remainder of this tutorial.
Shutdown
CAUTION: To kill all apps and shutdown a Mac right away (with no warning and no dialog):
sudo shutdown -h now
Text Command Line Bash Shortcuts
These come from the bash terminal on Linux machines here: Press control with your pinkie, then …
Environment Variables
A big reason to use a command-line terminal is to set environment variables.
Like on PCs, the PATH system environment variable storeswhere the operating system should look to find a particular program to execute.
Default editor
Command history
Foreground processes and background jobs
Folders accessed by developers
Terminal File Listing Home Folder
By default, the Terminal shows the hard drive and lowest level file folder name, in white letters over black.
Show Hidden Invisible Files in Finder
By default, the Mac’s Finder does not show hidden files.
For more on this, see this.
Create Terminal AliasesWireless up and down
Most developers leave files un-hidden.
tree alias or brew install
OSX does not come with the tree command that many other Linux distributions provide. So add it using:
If you don’t want to install a program, add an alias for a tree command by adding this in the ~/.bash_profile script:
Alternately, add it by installing a command using brew:
Active Terminal sessions need to be closed so new Terminal | Shell | New Window | Shell has this activated.
See list of parameters:
List only 2 levels deep with human-readable file size kilobytes and sort by last modified date:
Cursor to Screen Hot Corners
By default, if you move the mouse to one of the corners of the screen,stuff happens. It can be annoying.
Hosts file
Mac, Windows, and Linux systems have a hosts file that locally does the work of the public DNS– translating host names (typed on browser address field) to IP address numbers.
Terminal Ping Host
Find the IP address of a website host name:
SSH tunnel
To access a remote server through a port that is not open to the public:
DNS Configuration with NameBench
Analysis at one time showed this ranking by speed:
Google Namebench tries the speed of various DNS servers from YOUR machine (which takes some time) and pops up in your browser this:
An example:
Clear DNS Cache
Different commands are needed for different versions of OS.OSX 10.10 added requirement for sudo when using the built-in discoveryutil:
sudo discoveryutil udnsflushcaches
Bash Profile Configuration
The profile file is run during boot-upto configure the terminal to define file path, shims, and autocompletion handlers.
This is the single biggest frustration with people using Linux on Mac.
One of the earliest articles on bash hereshows shell variables, environment variables, and aliases.
Each operating system has its own file name for its profile:
PROTIP: If there is both a .bash_profile and a .profile file, boot-up only executes the first one it finds.
According to the bash man page, .bash_profile is executed during login before the command prompt,while .bashrc is executed for interactive non-login shells such aswhen you start a new bash instance by typing /bin/bash in a terminal.
Here’s what my profile file begins:
https://github.com/gcuisinier/jenv/blob/master/README.md
Operating System Kernel
I can use Linux commands in my version of the operating system:
uname -a (a for all) or uname -rvm
returns:
14.3.0 Darwin Kernel Version 14.3.0: Mon Mar 23 11:59:05 PDT 2015; root:xnu-2782.20.48~5/RELEASE_X86_64 x86_64
which is a combination of:
uname -r for release number,
uname -v for kernel version, uname -m for model:
x86_64 for Intel or AMD 64-bit or
i*86 for 32-bit.
For more information about Darwin operating systemdeveloped at Apple, see:
NOTE: lsb_release -awhich works on Debian, RHEL 6.6, and Ubuntu is not recognized on Gentoo nor CentOS 6,which has no folder /etc/lsb-release.
See Distriwatch.com,which describes releases of different Linux distributions.
Setup Your Mac Like a Pro
Paul Irish is one of top pros among developers, and now a Google Evangelist.He put his Mac configuration settings ongithub.com/paulirish/dotfiles. But he recommends cloning github.com/mathiasbynens/dotfiles/.
On the Git page notice that he has established an industry convention of usingProjects folder we defined earlier.
On the Git page I clicked on Clone in Desktop. https://angelstree529.weebly.com/real-time-player-for-mac-free-download.html.
The library is called dotfiles because that’s what hidden files are called,and most configuration files are hidden. Download hiren boot cd 10 6 26.
PS1 terminal prompt setting
Paul Irish offers his setup-a-new-machine.sh athttps://github.com/paulirish/dotfilesZShell (included with Mac and can be set as the default in Terminal)* oh-my-zsh as a ZShell framework* The oh-my-zsh Git plugin* And the oh-my-zsh theme called jnrowe</p>
By default, if you have a long file name, it would leave little room to type in commands before it wraps to the next line.
To redefine what appears in the prompt,edit this file using the vi editor that comes with each Mac:vi .bashrc Copy this and paste to the bottom of the .bashrc file:
The command above uses global parameters $USER and $PWD,plus colors from this list.
Root user for sudo commands
If you try a command that responds about “permissions denied”, you need to execute as a root user.
The root user has the ability to relocate or remove required system files and to introduce new files in locations that are protected from other users. A root user has the ability to access other users’ files.
Any user with an administrator account can become the root user or reset the root password.
Under a *nix system like MacOS you must have “root” (administrative) privileges to start IP-services using ports smaller than 1024.
After MacOS install, the root or superuser account is not enabled. While it is possible to enable the root account, once enabled, if forgetten, you’ll have to reboot from the installer drive (a hassle).
PROTIP: There are several ways to invoke sudo*
PATH
NOTE: The folders that bash looks into are in bin:
/bin/echo $PATH
On a fresh Yosemite, that would contain:
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
Each additional app adds to the front of the list:
/Library/Frameworks/Python.framework/Versions/3.4/bin:/opt/local/bin:/opt/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
Separating the folders between colon separator:
New folders are added to the front of the PATH using a command such as:
export PATH=<new folders>:$PATH
Depending on how you’re setup, file ~/.profile or ~/.bash_profile or ~/.bash_login contains the path echo’d.
Or your PATH may be set in /etc/profile for all users
Create Windows-like shortcuts with parameters using text editor
http://www.jesseweb.com/coding/automator/create-windows-like-shortcuts-with-parameters/
Mac OSX doesn’t allow you to create shortcuts like Windows.OSX alias don’t allow parameters (ex. create a Screen Sharing shortcut that connects to a specific computer).
![]()
Jessie suggests this to create a Windows like shortcut with parameters in the Comments field.
Another alternativeis to use a text editor to create URL shortcut fileslike the ones Windows Internet Explorer stores its bookmarks. Apple Safari recognizes them when clicked within Finder.So they are cross-platform.
Mount .dmg files using hdiutil tool
IPv6 compatibility with Curl command line apps
curl http://localhost:3000
Previously, when invoked on Mac OS 10.10 (Yosemite), you needed to add a parameter to make the request use IPv4:
curl http://localhost:3000 –ipv4
Otherwise, even if the URL loads fine in a browser, you will see an error message such as:
curl: (7) Failed to connect to localhost port 3000: Connection refused
This occurs because curl, under Yosemite, uses IPv6 by default but some apps, such as LoopBack.io, by default uses IP v4.
See if you see IP v6 entries in your hosts file (::1 localhost, fe80::1%lo0 localhost). If they are there it is likely that curl is making requests using IP v6.
You can make your LoopBack app use IPv6 by specifying an IPv6 address as shown below:
Largest files taking up disk space
Linux has a ncdu (NCurses Disk Usage) utility to list files in order of how much space they occupied.
Empty Trash
When files or folders are moved to Trash, they are sent to folder
~/.Trash .
Mac Terminal Program
To recover disk space taken up by files which have been moved to Trash, there are several ways:
Ulimit Too Many Files
By default, operating systems limit how many file descriptors to allow.Each operating system version has a different approach.
Linux operating systems have this command:
ulimit -a
On my Sierra the response was:
Zoho sales app. PROTIP:
launchctl is a rough equivalent to the systemctl command used in Linux systems.launchctl interfaces with launchd to load, unload daemons/agents and generally control launchd.
Disable System Integrity Protection
Some programs make calls to the operating system which OSX began to see as a threat, beginning with El Capitan.
Apple says System Integrity Protection blocks code injection (and many other things).
But what about useful programs (such as XtraFinder)which works by injecting its code into Finder and other application processes?
To get around this, you need to partially disable System Integrity Protection in OS X El Capitan.See Apple’s article on how:
Skill Certification
Video course Mac OS X Support: Installation and Configureis the first of courses on Plurasight towardApple Certified Support Professional (ACSP)
Dotfile Settings from othersMac Osx Terminal Open File With Application
Daemons and Agents
Mac Os Terminal Install CommandResources:
[2] VIDEO Download garamond font mac free.
[3] Advanced Bash-Scripting Guide by Mendel Cooper 2012
[4] CommandLineFu.com
https://zwischenzugs.com/2018/01/06/ten-things-i-wish-id-known-about-bash/https://leanpub.com/learnbashthehardway
https://blog.flowblok.id.au/2013-02/shell-startup-scripts.htmlhttps://bitbucket.org/flowblok/shell-startup/src/default/
https://linuxaria.com/howto/7-hidden-features-of-bash
More on OSXMac Osx Terminal Open File With App Windows 10
This is one of a series on Mac OSX:
Please enable JavaScript to view the comments powered by Disqus.
Mac Osx Terminal Open File With AppropriateComments are closed.
|
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |