This is an old revision of the document!
Corning Community College
CSCS1730 UNIX/Linux Fundamentals
Course Wiki Page
Projects
URLs
Linux Kernel-Repo (Linus Torvalds) https://github.com/torvalds/linux
Notes
I feel like there should be some beautiful words of knowledge contained on this page, so I have decided to do my best attempt at making it that way.
Vim/Vi Command Mode Commands
- Escape key leads to command mode.
- 'i' leads to insert mode at the current space.
- Navigation is accomplished through h (right), j (down), k (up), l (left).
- 'a' leads to insertion mode at the next space.
- 'I' leads to insert mode at the beginning of the line.
- 'A' leads to insert mode at the end of the line.
- 'o' leads to insert mode on a new line after the current line.
- 'O' leads to insert mode on a new line before the current line.
- 'w' is move forward a word (stop not just at spaces, but also / . , ? and more).
- 'b' is move back a word (same as above).
- 'W' and 'B' move forward and backward a word (only stop at spaces).
- '.' repeats the last command.
- '^' and '$' take you to the beginning and end of lines respectively without going into insert mode.
- '{' and '}' take you to the previous and next paragraphs. [Side Note: many of these commands can be prefixed with a number, which means you want the command to be executed that many times].
- 'x' deletes the next character.
- 'X' is cutting (acts like backspace).
- You can also do commands like dw, db, d^, d$, d{, d}, dd which do a delete operation related to the letter after the 'd' (dd deletes the current line).
- 'v' allows you to highlight text by moving around with the arrow keys.
- 'y' is yank (essentially just 'copy'). There must be text highlighted for this to work.
- 'p' pastes below and 'P' pastes above.
Regular expressions
In a sort of a related note, as vi uses some regular expressions patterns, this section will cover regular expressions and pattern matching. In Unix regular expressions are used to give a user/admin the capability to search based on patterns. Regular expressions, or regex, or regexp is a very useful tool. The common patterns are the followings:
- '.' –> indicates match every characters
- '^' –> match the beginning of a string or file(As in Vi)
- '$' –> match the end of a line of file(As in Vi)
- '[a-zA-Z]' –> match all letters uppercase and lowercase
- '[0-9]' –> match only digits from 0-9
- '[0-9]*' –> match 0 or more digits
- '[0-9]+' –> match 1 or more digits
- '[a-d]?' –> match 0 or only one occurrence of a-d lowercase
- '[0-9]{x, y}' –> match digits at least x times, and less than y times
*These are few common patterns in regex.
Other
Quick Tip:
Recently I have discovered a trick that could help run scripts much quicker with direct access to one's lab46 account, without working only on a single a single. Ultimately, I had to ssh into my account, and whenever I left the terminal open for a few minutes, it would go offline - or had share scripts between my personal laptop and lab46 machines, and work on projects on one machine at a time(fairly painful). With this method one can easily call commands anywhere, that are otherwise only available on the lab46 account. Here is how it is accomplished:
ssh account@lab47.corning-cc.edu command_here
A working example would be the following:
#From my own laptop current_grades=$(ssh user@lab46.corning-cc.edu status unix) #This example would return grades from the user.
Note that the script would prompt you to enter your password.