|
i - insert at cursor (goes into insert mode)
|
ESC - Terminate insert mode
|
|
a - write after cursor (goes into insert mode)
|
u - undo last change
|
|
A - Write at the end of line (goes into insert mode)
|
U - undo all changes to the entire line
|
|
dd - delete line
|
o - open a new line (goes into insert mode
|
|
3dd - delete 3 lines
|
C - delete contents of a line after the cursor and insert new text
|
|
dw - delete word
|
r - replace character
|
|
4dw - delete 4 words
|
R - overwrite characters from cursor onward
|
|
cw - change word
|
s - substitute one character under cursor continue to insert
|
|
x - delete character at the cursor
|
S - Substitute entire line and begin to insert at the beginning of the line
|
|
~~ change case of individual character
|
|
|
k - move cursor up
|
h - move cursor left
|
|
j - move cursor down
|
l - move cursor right
|
|
Shift+zz: save the file and quit
|
:q - quit without saving
|
|
:w - save the file but keep it open
|
:wq - save the file and quit
|
|
> : send output to file or another device
|
>> : appends new file to an existing file
|
|
< : reverse redirection, takes input for program from existing file instead of keyboard
|
> : redirection, combined with system commands to achieve any desired results
|
|
!! : current history
|
wc : word count
|
|
Ctrl-c: stop current command
|
Ctrl-a: go to start of line
|
|
Ctrl-z: sleep program
|
Ctrl-e: go to end of line
|
|
Ctrl-u: cut from start of line
|
Ctrl-k: cut to end of line
|
|
Ctrl-R: read file
|
Ctrl-O: save file
|
|
Alt-A; start marking text
|
Ctrl-X: close file
|
|
Ctrl-K: cut marked text or line
|
Ctrl-U: paste text
|
|
ALT-/ End of file
|
CTRL-E: End of line
|
|
CTRL-A: Beginning of line
|
CTRL-C: Show line number
|
|
CTRL-W: Find
|
ALT-W: Find next
|
|
CTRL-\: Search and replace
|
|
|
# Display the user and group ids of your current user.
|
# Display the last users who have logged onto the system.
|
|
id
|
last
|
|
# Show who is logged into the system.
|
# Show who is logged in and what they are doing.
|
|
who
|
w
|
|
# Create a group named "test".
|
# Create an account named john, with a comment of "John Smith" and create the user's home directory.
|
|
groupadd test
|
useradd -c "John Smith" -m john
|
|
# Delete the john account.
|
# Add the john account to the sales group
|
|
userdel john
|
usermod -aG sales john
|
|
#Display Linux system information
|
#Show system host name
|
|
uname -a
|
hostname
|
|
#Display kernel release information
|
# Display the IP addresses of the host
|
|
uname -r
|
hostname -I
|
|
# Show which version of redhat installed
|
#Show the current date and time date
|
|
cat /etc/redhat-release
|
date
|
|
# Who you are logged in as
|
# Display who is online
|
|
whoami
|
w
|
|
# Show this month's calendar
|
# Show system host name
|
|
cal
|
hostname
|
|
#Search for pattern in file: grep pattern file
|
# Search recursively for pattern in directory: grep -r pattern directory
|
|
# Find files and directories by name: locate name
|
# Find files in /home/john that start with "prefix": find /home/john -name 'prefix*'
|
|
# Find files larger than 100MB in /home: find /home -size +100M
|
# Connect to host as your local username: ssh host
|
|
# Connect to host as user: ssh user@host
|
# Connect to host using port: ssh -p port user@host
|
|
grep 'word' filename – Search any line that contains the word in filename on Linux
|
grep -i 'bar' file1 – A case-insensitive search for the word ‘bar’ in Linux and Unix
|
|
grep -R 'foo' . – Search all files in the current directory and in all of its subdirectories in Linux for the word ‘foo’
|
grep -c 'nixcraft' frontpage.md – Search and display the total number of times that the string ‘nixcraft’ appears in a file named frontpage.md
|
|
# List all files in a long listing (detailed) format
|
# Display the present working directory
|
|
ls -al
|
pwd
|
|
# Create a directory
|
# Remove (delete) file
|
|
mkdri directory
|
rm file
|
|
# Remove the directory and its contents recursively
|
# Force removal of file without prompting for confirmation
|
|
rm -r directory
|
rm -f file
|
|
# Forcefully remove directory recursively
|
#Copy file1 to file2
|
|
rm -rf directory
|
cp file1 file2
|
|
# Copy source_directory recursively to destination. If destination exists, copy source_directory into destination, otherwise create destination with the contents of source_directory.
|
# Rename or move file1 to file2. If file2 is an existing directory, move file1 into directory file2
|
|
cp -r source_directory destination
|
mv file1 file2
|
|
# Create symbolic link to linkname
|
# Create an empty file or update the access and modification times of file.
|
|
ln -s /path/to/file linkname
|
touch file
|
|
# Display the first/last 10 lines of file
|
#View/browse the contents of file
|
|
head line/tail line
|
cat file/less file
|
|
# Display the last 10 lines of file and "follow" the file as it grows.
|
tail -f file
|
|
user group/other permissions - link account - user - group - filesize - date - filename
|
r : read, w : write, x - excute
|
|
/ to find
|
\> : searches for the next word that ends with a specific string
|
|
[] : finds the characters between brackets
|
/< : searches for the next word that begins with a specific string
|
|
$: searches for the line that ends with a specific character
|
:! - leave vi tempo
|
|
:q - cancel an editing session
|
:wq - write changes to disk and exit vi
|
|
ZZ: in command mode, save changes and exit vi
|
u : undo most recent change
|
|
/ to find
|
\> : searches for the next word that ends with a specific string
|
|
[] : finds the characters between brackets
|
/< : searches for the next word that begins with a specific string
|
|
/ to find
|
\> : searches for the next word that ends with a specific string
|
|
[] : finds the characters between brackets
|
/< : searches for the next word that begins with a specific string
|
No comments yet.
Cheatography n. The art of mapping complex subjects into clear, instantly navigable reference guides.