Start in the Shortcuts directory and enter the following commands, using the arrow keys to simplify your job:$ cd directory1/directory2/diectoryr3 (remember the Home key and the Ctrl key with left and right arrows)$ cal > directory4/file3 Step 2 - Using the TAB keyLinux has short, cryptic command names to save you typing - but it is still a command line interface, and that means you interact with the operating system by typing in commands. Also, if you hold down the Ctrl key when you type an arrow key, the cursor will move by an entire word instead of a single character - this is useful is many situations and works in many editors.Let's use this to create a directory hierarchy and a few files. Using the up and down arrow keys, you can recall previously-entered commands to the command line, edit them and re-issue them.Note that in addition to the left and right arrow keys you can use the Home and End keys to move to the beginning or end of the command line. Play around with this until you get a good feel for what is happening.Linux maintains a history of commands you have entered. Note you can also position the cursor before the capital C and hit Delete to get rid of it.Once you have changed the capital C to a lower case c you can hit Return to enter the command - you do not have to move the cursor to the end of the line.Now hit the up arrow key a few times, then hit the down arrow key and notice what happens. Or what if you have to type several similar commands - wouldn't it be nice to have a way to recall a previous command, make a few changes, and enter the new command? This is what the up arrow is for.Linux should tell you there is no directory with that name.Now type the up arrow key - the previous command you entered shows up on the command line, and you can use the left arrow to move the cursor just after the capital C, hit Backspace, and type a lower case c.Now tryAs you would expect, Linux completes the name "different-file"Notice Linux completes as much of the name as possible. Because there is only one file in the directory whose name begins with "oth", when you hit the Tab key Linux is able to complete the name.Hit Return (if you haven't already) to enter the cat command. The TAB key gives you a way to enter with commands with less typing and less memorization.Now type the following, without hitting the Return key:What happened? Linux completed the name "other-file" for you! The Tab key is your way of telling Linux to finish the current word you are typing, if possible. Not only that, but you have to remember the names of files and directories you type in.What do you think should happen? Step 3 - The Exclamation PointHitting the up arrow key is a nice way to recall previously-used commands, but it can get tedious if you are trying to recall a command you entered a while ago - hitting the same key 30 times is a good way to make yourself feel like an automaton. Now type the letter f followed by a Tab. Don't hit Return yet. Your command line should look like this:Don't hit Return yet. Your command line should now look like this:If you hit Return, Linux will tell you that directory2 contains directory3.Then type another d followed by then another d followed by tab. This is because there is only one file in the Shortcuts directory whose name begins with "dir"Hit Return and Linux will tell you that directory1 contains directory2.And before you hit return type another d followed by another Tab. Aha! Linux shows you the possible choices for completing the word.The Tab will not add anything - the command line will still readNow type the letter o followed by a Tab - once you add the o there is only one possible completion - "folio".$ cat directory1/directory2/directory3/directory4/file3Now type the following without entering Return:Nice! As you would expect, Linux completes the name of the directory for you.
![]() Sometimes you just aren't sure what you need to type after the exclamation point to get the command you want.Typing Ctrl-r (that's holding down the Ctrl key and typing a lower case r) is another way to repeat previous commands without having to type the whole command, and it's much more flexible than the bang. Step 4 - Ctrl-rOne problem with using the exclamation point to recall a previous command is that you can feel blind - you don't get any confirmation about exactly which command you are recalling until it has executed. But if you enterThe last command re-executes the " cat" command. For example if you enterThe last command will redo the " cal" command. You can enter more than one character after the exclamation point in order to distinguish between commands. So " !c" means recall the last command that starts with the letter c, the " cal" command in this case. Step 5 - historyCool, huh? You get to see all the commands you have entered (probably a maximum of 1000.) You can also do something likeTo get all the commands with the word "cal" in them. So go ahead and play with it. This is one you have to play around with a bit before you understand exactly what it is doing. Type in " fi" (that's a space, an "f" and an "i") - did the command shown at the prompt change? Now hit backspace four times.Now enter a right or left arrow key and you will find yourself editing the matching command. To see it in action, type in the following commands (but don't hit after the last one):You should see the following on your command line:Try playing with this now. After you type Ctrl-r, start typing the beginning of a previously entered command - linux will search, in reverse order, for commands that match what you type. Now hit Ctrl-t (again, hold down the control key and type a lower case t.) What just happened? Try hitting Ctrl-t a couple more times. Now hit the up arrow key to recall this command and hist the left arrow key twice so the cursor is on the "e" of "file1". I don't find it particularly useful. If there is a command you enter a lot you can define a short name for it. Step 7 - The alias commandAnother nice feature of linux is the alias command. But somewhere out there is a linux black belt who gets extra productivity out of this shortcut. Frankly, it takes me more time to think about what is going to happen if I type Ctrl-t than it takes me to delete some characters and retype them in the correct order. Also, it moves the cursor to the right. Onedrive personal account sync for macSo enter the following:And hit return. You must be getting sick of typing " cat folio5".
0 Comments
Leave a Reply. |
AuthorShameka ArchivesCategories |