Terminal Commands Mac Tutorial - HOW TO USE TERMINAL ON MAC

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey everybody welcome to the apple ninja today we're going to go over command line terminal getting back to the basics going over a bunch of different commands i'm even hoping that i can show some of these longtime terminal experts out there some tricks and we're going to dive in it's going to be fun by the end of the video you're going to learn a bunch of stuff make sure you hang out to the end because i'm going to show you how to clear out all of this history of all of your uh commands that you've typed in so you kind of leave no trace on the system also i'm going to show you a handy dandy trick on how to show hidden files on the system quickly and easily so let's dive in we're going to open up the command line terminal by hitting command spacebar to initiate spotlight or you can go up and hit the magnifying glass just type in terminal then i'm going to hit command plus to blow it up and i'm going to stretch that guy out all right so i want my terminal to kind of look matrix-like so i'm going to go up to terminal preferences and i'm gonna open up and choose homebrew all right and then i'm gonna close that i'm gonna close this window quit out of terminal command spacebar again open it up all right and let's blow that up again now that i got the cool looking terminal all right so all of these commands let's just start off with all of these commands that i'm going to go over you can look at the manual page for each of them by typing in mn and the command so let's just do the ls command and this is the list directory content so this is a good one to get to know um i can scroll down by using the arrow keys down and up all right i can search this by hitting command f and searching for some sort of uh whatever i'm looking for if i want to type in symbolic because i see it on the screen you're going to see it flash and i can search if i want to exit i hit q alright and so that's how you access the manual page sometimes commands don't have man pages but you might end up having to type like ls minus h for a help page um that obviously didn't do that because that's not what this command has it has a man page and h was an actual option that it has so the command i'm going to run um is going to be pwd and that's going to show me the current working directory so that's going to tell me where i'm at and you're going to see that by this tilde right there that tells me that i'm in my user folder this is the user that this shell is launched with and this is the name of the whole system this mac so if i type in ls and i do a whack and i'm just gonna type some stuff out and we know that safari is an app okay so if i want to go to the beginning of this line i'm going to do control a if i want to delete that ls i do control d and if i want to go to the end of the line i can do control e if i want to arrow over actually if i want to do an option arrow to the left it's going to hop option arrow to the right it's going to hop and let's say i hop into the center of this if i hit control u it's gonna delete everything be before the cursor cursor to the beginning of the line right so i still have everything at the cursor to the end but if i hold ctrl k it's going to delete everything from the cursor to the end of the line all right so now we've deleted um so if i want to clear this screen out i can do command k and that'll just clear the whole screen out so those are some navigation tips for kind of navigating that line because sometimes your your line arguments and everything it ends up being really long you end up with super long commands so now we know that we're in the user's apple ninja what if i want to go to the root of the hard drive so i can just type in cd for change directory and i can type in a whack and i go to the root of the hard drive i can type in ls here and see a listing of files in folders but let's say i want this ls command to show me more information i can type a dash and i'm going to do an l for long format i want to see all sorts of information about each one of these items in there i want to do an a to show me any hidden files i want to do an h to show me sizes of the files and folders it doesn't this doesn't do a good job of showing the folders but i'm going to show you another way right after this and i'll run it when i run this the long format shows me all this long formatted line right the a is going to show me all the hidden stuff with the dot in the front as you can see right here then the h is going to try to tell me the size of that folder in human readable if i do g and f and these can be in any order the g is going to color code it the f is going to add wax on the back of the folders and it's going to add like a's to aliases so let me just run this and you're gonna see now all the app all the folders are a different color and they have a whack after it all the aliases are a different color and they have an ad symbol and it shows where it's pointing to so that's kind of nice way to list out and show that information now if i wanna go back to my because i'm in root right now in the root directory if i want to go back to my home folder i just cd use tilde and i'm back there so now i can arrow up run that command on the desktop folder and let's say i start typing desktop i can hit tab to auto complete that um all right and we're going to hit enter and it's going to show a bunch of files bunch of movies it's actually showing the correct size of these files right but if i want to know the size of this entire desktop folder what i can do is i can arrow up now go back and i'm going to delete this command and i'm going to use du minus sh du is the disk usage command when i run this i'll be able to get the entire desktop contents and the size which is kind of nice to be able to grab that all right so now that we've done a little bit on how to navigate around a little bit and show what sizes and listing out files let's try to open something so i can type open and just drag a file in there boom and it's going to open it right as long as i have access to open it if i didn't own this file i would have to type in sudo in front of that last command so if i type in to exclamation marks it's gonna tell it's gonna do pseudo which means elevate this command this next command with elevated permissions but it's gonna run this whole thing so i'm gonna just type that and as you'll see sudo open it does the whole command by doing the double exclamation marks and i'm just going to type in the password and it's going to do it all right so that's using sudo to when you don't have access to a file you end up having to use elevated admin permissions so that is going to require a password all right so let's move on we're going to copy this file so if i just drag this file control a to go back to the beginning if i do a copy and then ctrl and i can just do users shared and it'll copy that file into my user shared i can type in open wac users shared that'll open the folder and show us the file all right let's say i want to move a file and i don't want to copy i can type in move and actually i'm gonna do something kind of slick i'm gonna drag this screen recording i got a bunch of these screen recordings on my desktop so i want to move them all at once here's a power tip you're gonna put an asterisk on the end so that it's screen recording and anything else that's after that covers it all so i'm gonna move this entire i want to move this whole thing over into oh i had a folder one second i want to move all those screen recordings into the screenshots folder i'm going to drag that screenshot folder in there and i'm just going to put a whack on the end and you're going to see it happen boom and now they're all in there which is a sweet way to move a bunch of files uh super quickly all right so now we've done the move and the copy let's see what the inside of this keyword stats file if i spacebar you're going to see that this was from uh keyword planner i was grabbing a bunch of stats on apple uh keyword items i want to see what's in that with the cat command and you can basically go through oh man tons of information in that file so that's how you look at the inside of a file using cat i'm going to do a command k to clear that screen up and now let's say i want to know how many words are in this file it's it it's got a ton of lines and words and we're going to see we're going to use the wc minus c and i'm going to drag this file in there and it's going to tell me there are 712 776 words let's check out how many lines are in there if i hold down option you're gonna see crosshairs and i can drop this cursor wherever [Music] all right and i'm gonna hit l so 4336 lines in that file it's kind of fun information to find and now if i don't want this file anymore i can just type in remove and drag that file in there boom and it's gone just note if i type in remove and i type in desktop here it's it it can delete everything i would have to do um i would have to actually have a different option on here but you need to be careful what you're typing in so that you don't remove a bunch of files that unintended files right especially when you're doing a pseudo remove which can literally wipe your whole hard drive if i did um a force on this it it actually a four sam recursive i believe and i if i were to run this on this it would delete it would try to delete the whole hard drive on me right so you want to be very careful when running the remove command and always try to auto fill right so let's say i started typing this just hit tab oh oh it's gone so ah yeah you want to hit tab you want to make sure you auto complete right apple ninja desktop and let's say i want to delete this mac os big sur i'm auto completing by hitting tab all right so i don't want to control you again to delete all that all right so um if i want to find out my ip address on this system i can run ifconfig and it's going to give me a ton of information i can scroll up here keep scrolling up to en0 that's usually it unless you have a vpn connection if you have a vpn connection you're going to have the en0 as well as a u-turn address down here and you'll be able to see the actual vpn address as well from running this all right next thing i want to do a command k clear that screen let's ping apple so we're going to ping apple.com and this shows that i am able to connect to and reach apple.com on that ip address and let's say i want to just see some more information about apple apple.com all right and now we can see all the different addresses and all these different host names that are associated with this apple.com address which is kind of nice to see that kind of information all right so we've typed in a lot of commands and gone through a bunch of different stuff now if i want to see what i've worked on this entire session i can just type in history and it's going to show me all the commands that we have gone through in this session if i want to clear those out i can type history minus c and it will clear out all the commands that i just ran so now if i type in history you're not going to see anything what what you need to know is that if i had quit out of this uh session without clearing that history it will store it in a file called bash underscore history so if you remember when i did a ls minus la on this folder here you're going to see this bash history so let's go take a look at this so we're going to use cad to read the file and we're going to do bash history i'm just going to see what's in there all right it's got a bunch of information that i ran before so if i want to completely clear out my history from this i'm going to delete that and i'm going to type a remove and i'm just going to get rid of the bash history all together quit out of my terminal reopen my terminal and i'm not going to have anything except for a blank slate right it shows what i have in there and that's it um that's how you clear out all that stuff so now that you've completely cleared it last thing that i wanted to show you was how to show the hidden files on your system super easy hold down command shift period and command shift period to hide them again this is global it shows all the hidden files on your system uh throughout so if you keep it like that you're gonna see random locations that have files in there all right guys i hope you enjoyed this video please throw it a thumbs up and a like and all that good stuff get subscribed also i want to throw a shout out to my buddy that runs mr mcintosh and my other buddy that runs swift goose go check out those youtube channels man they're awesome you guys have an amazing day can't wait to see in the next video take care
Info
Channel: Apple Ninja
Views: 2,223
Rating: undefined out of 5
Keywords: Mac, macOS, mac terminal commands, open terminal mac, best terminal for Mac, mac terminal shortcut, open finder from terminal, mac os terminal, clear terminal Mac, how to use terminal on Mac, open terminal in folder Mac, MacBook terminal, apple terminal, terminal app Mac, show hidden files Mac terminal, open terminal Mac shortcut, terminal show hidden files, macbook terminal commands, terminal window Mac, mac terminal ipconfig, apple ninja, Terminal Commands Mac Tutorial
Id: RE0eKQ8KOXY
Channel Id: undefined
Length: 18min 2sec (1082 seconds)
Published: Fri Aug 20 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.