Home PC Games Linux Windows Database Network Programming Server Mobile  
  Home \ Linux \ 3 tips Linux command     - Ubuntu file security removal tool (Linux)

- Network security system (Network)

- To configure and use multiple Tomcat under Linux environment (Server)

- Let the terminal under Mac OS X as like Linux has displayed a variety of colors (Linux)

- Simple security measures to reinforce the Linux kernel (Linux)

- Basic Tutorial: Linux novice should know 26 commands (Linux)

- How to create a someone project on github (Linux)

- RHEL 7.1 compile and install Ganglia 3.7.1 (Server)

- GoldenGate update is missing (Database)

- ORA-28000 the account is locked fault simulation (Database)

- Linux - Common process the command (Linux)

- Spring JDBC Comments (Programming)

- File sharing and fork function (Programming)

- Efficient Linux Shell - Shell special characters Summary (Linux)

- Docker: installation under Ubuntu (Server)

- Oracle11g CRS-0184 Problem Solving (Database)

- Swift used in the application to add a local push at the specified time (Programming)

- Forwarding module with Apache reverse proxy server (Server)

- Ubuntu 12.04 64bit Install Source Insight 3.5 and create desktop icons (Linux)

- CentOS 6.5 set under Oracle 12c at startup (Database)

  3 tips Linux command
  Add Date : 2018-11-21      
  Linux world is full of fun, the more we go in depth, you will find more interesting things. We will try to give you some tips so that you and others are different, here is what we prepared three small skills.

1. How does the case of using the task scheduler Cron under Linux in

In Linux, a task scheduler / command called Cron. When we need to schedule a task, we will use Cron, but you know we're not used Cron also can schedule a task to run in the future of time? You can follow the following suggested actions ......

Run a command every 5 seconds (date) and then writes the results to a file (data.txt). To achieve this, we can run the following one-line script directly from the command prompt.

$ Whiletrue; do date >> date.txt; sleep 5; done &
Above script explanation:

while true: let the script enters a loop condition is always true, that is manufacturing a dead cycle, repeated over and over again inside the command to run.
do: do while statement is a keyword, the command will be executed after it, it can be placed behind one or a series of commands.
date >> date.txt: Run date command and writes its output to the data.txt file. Note that we use >> instead of>.
>>: File (date.txt) additions to the write operation, so that after each run command, the output will be appended to the file. If> then this will overwrite the previous content over and over again.
sleep 5: the script to sleep in five seconds, and then run the command later. Note that the only time unit in seconds. This means that if you want the command to run once every 6 minutes, you should use the sleep 360.
done: while loop end of the block tag.
&: The entire process into the background.
Similarly, we can run any script. The example below is run every 100 seconds a script called script_name.sh of.

Also worth mentioning is the script file mentioned above must be in the current directory, or need to use the full path (/home/$USER/.../script_name.sh). One-line script to achieve the above functions as follows:

$ Whiletrue; do / bin / sh script_name.sh; sleep 100; done &
Summary: The above is not a one-line script Cron alternatives because Cron tool supports many options, more flexibility, customization is also higher. However, if we want to run some tests, such as I / O evaluation, said one-line script is also useful.

2. How does the use of clear command to clear the contents of the terminal

How do you empty the contents of the terminal? You might think this is a silly question. Well, we all know you can use the clear command. If you develop using ctrl + l shortcuts habit, we will save a lot of time.

Ctrl + l effect shortcut and clear commands. So the next time you can use ctrl + l to empty the contents of the terminal.

Summary: Because ctrl + l is a shortcut, we can not use in the script. So if we need to empty the contents of the screen in the script, or the need to use the clear command. But I can think of all the other cases, ctrl + l are more effective.


3. Run a command in a different directory, then automatically return to the current working directory

This is a lot of people may not know the amazing skills. You might want to run any command in a different directory, then back to the current directory. To achieve this purpose, you only need to put a command in parentheses.

Let's look at an example:

avi @ deb: ~ $ (cd / home / avi / Downloads /)
Sample output:

avi @ deb: ~
It will first cd to the Downloads directory, then back to the previous home directory. Maybe you think the inside of the command is not executed, or that something is wrong, because from the command prompt do not see any change. Let's look at a simple modification of this order:

avi @ deb: ~ $ (cd / home / avi / Downloads / && ls -l)
Sample output:

-rw-r ----- 1 avi avi 54272May318: 37 text1.txt
-rw-r ----- 1 avi avi 54272May318: 37 text2.txt
-rw-r ----- 1 avi avi 54272May318: 37 text3.txt
avi @ deb: ~ $
In the above command, it first entered the Downloads directory, then list the contents of the file, and finally back to the current directory. And it proves that the command executed successfully. You can include any command in parentheses, will be executed after the successful return to the current directory.
- SUSE Linux network configuration and firewall configuration (Linux)
- Simple configuration shell scripts virtual machine environment experiment (Linux)
- MyEclipse configuration necessary (Linux)
- Nmcli based network management command-line tool (Linux)
- Workspace Go language and environment variables GOPATH (Linux)
- libreadline.so.6: can not open shared object file problem solution (Linux)
- RCU lock in the evolution of the Linux kernel (Linux)
- Python data types summary (Programming)
- How to run Kali Linux 2.0 in Docker container (Linux)
- C ++, overloading, cover, hide (Programming)
- Nginx reverse proxy and self-signed https (Server)
- Learning OpenCV: (VS2010-openCV2.4.3-win7 configuration instructions) (Linux)
- MySQL IO SSD attempt at optimization (Database)
- NET Developers need to know some Linux commands (Linux)
- To remove those IP is prohibited Fail2ban on CentOS 6/7 (Server)
- To use slay kill user processes (Linux)
- Linux operating system security can not be ignored (Linux)
- MyCAT separate read and write to achieve MySQL Practice (Database)
- Based AutoYaST automated installation of SUSE practice (Linux)
- Create your own YUM repository (Linux)
  CopyRight 2002-2022 newfreesoft.com, All Rights Reserved.