Home PC Games Linux Windows Database Network Programming Server Mobile  
  Home \ Linux \ 20 Unix / Linux command skills     - MySQL uses mysqld_multi to deploy stand-alone multi-instance detail procedures (Database)

- CentOS 6.5 installation and simple configuration Nginx (Server)

- Oracle 11g RMAN cross-platform transfer table space (Database)

- Linux Network Programming - signal blocking and shielding (block, unblock) (Programming)

- iOS development -Launch Image and Launchscreen (Programming)

- How to test your MongoDB application upgrade? (Database)

- Ubuntu under VirtualBox virtual machine serial port settings (Linux)

- Redmine Installation (Linux)

- Use Visual Studio Code Development TypeScript (Linux)

- Achieve single backup of MySQL by innobackupex (Database)

- MySQL 5.5 on master-slave copy filter (Database)

- The basic method RHEL6 (CentOS6) used in the source package compiled RPM: Upgrade OpenSSH articles (Linux)

- C ++ 11 feature: decltype keywords (Programming)

- Linux command line under HTTP traffic sniffing tool: httpry (Linux)

- Android Studio utility plug organize, create sharp artifact (Programming)

- Iptables small summary (Linux)

- RHEL7.0 configuration CD-ROM to the local YUM (Linux)

- Ubuntu Froxlor Server Administration panel installation (Server)

- Using nmcli commands to manage network in RedHat / CentOS 7.x (Linux)

- TCP protocol flaw incomplete records (Linux)

  20 Unix / Linux command skills
  Add Date : 2018-11-21      
  Let us use these Unix / Linux command skills to open the new year to improve productivity at the terminal. I have been looking for a long time, and now share with you.

Delete a large file

I have a lot of 200GB of log files on the production server needs to be removed. My rm and ls command has collapsed, I am worried that this is due to the large disk IO caused large want to delete this file, enter:

> /path/to/file.log
# Or use the following format
:> / Path / to / file.log
# Then delete it
rm /path/to/file.log

How to record the output of the terminal?

Try using the script command-line tool to create output records for your terminal output.

script my.terminal.sessio
Enter the command:

sudo service foo stop
To exit (end session script), type exit or logout or by pressing control-D.

To browse Input:

more my.terminal.session
less my.terminal.session
cat my.terminal.session

Restore deleted / tmp folder

My article on Linux and Unix shell, I made some mistakes. I accidentally deleted the / tmp folder. To restore it, I need to do:

mkdir / tmp
chmod 1777 / tmp
chown root: root / tmp
ls -ld / tmp

Locking a folder

Data for my privacy, I want to lock / downloads files in my file server. So I ran:

chmod 0000 / downloads
root user can still access, and ls and cd commands will not work. To restore it with:

chmod 0755 / downloads

In the password-protected file with vim

Afraid of root user or other people peeping your personal files Why? Try vim with password protection, enter:

vim + X filename
Or, before exiting vim use: X command to encrypt your files, vim will prompt you to enter a password.


Clear garbled on screen

Just enter:


Accessible Formats

Transfer -h or -H (and other options) options to GNU or BSD tools to get like ls, df, du commands to format the output readable:

ls -lh
# In readable format (eg: 1K 234M 2G)
df -h
df -k
# In bytes, KB, MB or GB Output:
free -b
free -k
free -m
free -g
# Output readable format (such as 1K 234M 2G)
du -h
# Display file system permissions in readable format
stat -c% A / boot
Comparative figures read #
sort -h -a file
# On Linux display cpu information in readable form
lscpu -e
lscpu -e = cpu, node
# Display size of each file in readable form
tree -h
tree -h / boot

In the Linux system to display a known user information

Just enter:

## Linux version ##
## BSD version ##
Sample output:

0 root 0022: 37: 59 root
1 bin 01 bin
2 daemon 01 daemon
3 adm 01 adm
4 lp 01 lp
5 sync 01 sync
6 shutdown 012014-Dec17 shutdown
7 halt 01 halt
8 mail 01 mail
10 uucp 01 uucp
12 games 01 games
13 gopher 01 gopher
14 ftp 01 FTP User
27 mysql 01MySQLServer
38 ntp 01
48 apache 01Apache
68 haldaemon 01 HAL daemon
69 vcsa 01virtual console memory owner
72 tcpdump 01
74 sshd 01Privilege-separated SSH
81 dbus 01System message bus
89 postfix 01
99 nobody 01Nobody
173 abrt 01
497 vnstat 01 vnStat user
498 nginx 01 nginx user
499 saslauth 01 "Saslauthd user"

How do I accidentally deleted in the current folder unzip files?

I accidentally at / var / www / html / instead of / home / projects / www / current unpack a tarball. It messing up the / var / www html files under /, you do not even know what mistake unzipped. The easiest way to fix this problem are:

cd / var / www / html /
/ Bin / rm -f "$ (tar ztf /path/to/file.tar.gz)"

The output of the top command wonder?

Seriously speaking, you should try to use htop instead of top:

sudo htop

I want to run the same command again

Only you need to enter !!. such as:

/ Myhome / dir / script / name arg1 arg2
# To run the same command again
## Command as the root user to run the last run
sudo !!
!! Runs recently used commands. To run the recent run of "foo" and the beginning of the command:

! Foo
# Command to the root user to run a "service" at the beginning of
sudo! service
! $ Is used to run the command to bring the last parameter:

# Edit nginx.conf
sudo vi /etc/nginx/nginx.conf
# Test nginx.conf
/ Sbin / nginx -t -c /etc/nginx/nginx.conf
# Test End "/ sbin / nginx -t -c /etc/nginx/nginx.conf" You can use vi to edit the file again the
sudo vi! $

In the end you have to go remind

If you need a reminder to leave your terminal, enter the following command:

leave + hhmm

hhmm - time is of the form hhmm, hh represents hours (12-hour or 24-hour clock), mm is minutes. All times are converted to 12-hour, and is assumed to occur in the next 12 hours.

sweet Home

Just want to enter into the place? run:

cd -
We need to quickly return to your home directory? enter:

Variable CDPATH defines the search path to the directory:

export CDPATH = / var / www: / nas10
Now, do not enter cd * / var / www / html / so long, I can enter the following command into the / var / www / html:

cd html

Browse in less time editing the file

To edit a file being viewed with less, you can press v. You can use the variable $ EDITOR specified by the editor to:

less * .c
less foo.html
## Press v key to edit the file ##
After ## exit the editor, you can continue to use less viewed ##

List your system all files and directories

To see all the directories on your system, run:

find / -type d | less
# List all $ HOME directory
find $ HOME -type d -ls | less
To see all the files, run:

find / -type f | less
# List all files in $ HOME
find $ HOME -type f -ls | less

Directory tree with a single command structure

You can use the mkdir -p option to add a Create a directory tree:

mkdir -p / jail / {dev, bin, sbin, etc, usr, lib, lib64}
ls -l / jail /

Copy the file to multiple directories

You do not have to run:

cp / path / to / file / usr / dir1
cp / path / to / file / var / dir2
cp / path / to / file / nas / dir3
Run the following command to copy files to multiple directories:

echo / usr / dir1 / var / dir2 / nas / dir3 | xargs -n 1 cp -v / path / to / file
Leaving to create a shell function as exercise for the reader.

Quickly identify two different directories

diff command compares files line by line. But it can also compare two directories:

ls -l / tmp / r
ls -l / tmp / s
# Use diff compare two folders
diff / tmp / r / / tmp / s /

Find a different directory between

Text Formatting

You can use the fmt command to reformat each paragraph. In this case, I will split long lines and filled with short lines:

fmt file.txt
You can also split long lines, but not refilled, that split long lines, but do not fill short lines:

fmt -s file.txt

You can see the output and writes it to a file

Use the following command on the screen tee see the output and also written to the log file my.log in:

mycoolapp arg1 arg2 input.file | tee my.log
tee can guarantee you also see the output mycoolapp on the screen and written to a file my.log.
- Ubuntu 12.04 kernel configuration automatically restart and crash dump (Linux)
- dd command: do hard disk IO performance test (Linux)
- To install OwnCloud 7.0.4 under Ubuntu (Linux)
- Linux disk partition batch format mount script (Linux)
- Ubuntu font settings: Using Windows Font (Linux)
- 64-bit Ubuntu 15.10 How to compile the latest version of the 32 Wine 1.7.53 (Linux)
- Replace element and non-replaced elements of learning (Programming)
- Github Remote Assistance (Linux)
- Java threads in the life cycle (Programming)
- Whisker Menu 1.4.3 Install menu Linux (Linux)
- Nginx configuration support f4v video format player (Server)
- Django how to generate content in non-HTML formats (Programming)
- Use PuTTY to access the virtual machine Linux under Windows xp (Programming)
- How to become a better Node.js developers in 2016 (Programming)
- PostgreSQL log classification and management (Database)
- Red-black tree in C ++ (Programming)
- Elaborate .NET Multithreading: Concepts (Programming)
- Oracle 11g forget approach SYS and SYSTEM password (Database)
- OpenSIPS offline messaging feature set (Server)
- Linux shell string interception and stitching (Linux)
  CopyRight 2002-2020 newfreesoft.com, All Rights Reserved.