linux empty files and other useful instructions summary

  • 2020-05-14 05:51:27
  • OfStack

1). > filename

2). : > filename

3). echo "" > filename (file size truncated to 1 byte)

4). echo > filename

5). cat /dev/null > filename

6). cp /dev/null filename

cat a.log > > b.log adds append from a to b

cat a.log > b.log writes a content into b and overrides the original content in b


view newest logfile: tail -f logfile


View the packages package for all installations of the system: dpkg-query-l

View the services the system is listening for

# netstat - ln

To view all processes currently running on your system, use the following command:

# ps auxw

service[service name] performs the operation

Options and parameters:

Perform actions: work that the service needs to do (start|stop|status|restart... .).

-- status-all: displays all self-starting services of the system

Format: service < service >

Print specified service < service > Command line with help.


Format: service < service > start

Starts the specified system service < service >


Format: service < service > stop

Stops the specified system service < service >


Format: service < service > restart

Restart the specified system service < service > , that is, stop (stop) and then start (start).


Format: chkconfig --list

View the list of system services and the runlevel of each service.


Format: chkconfig < service > on

Set the specified service < service > It starts automatically when starting up.


Format: chkconfig < service > off

Set the specified service < service > Does not start automatically when starting up.

According to the startup mode of the service, it can be divided into two categories:

Self-booting services: most of the services that start when you boot up. Each service is controlled by one process

System 1 controls startup services: a separate process is responsible for starting these services, and the user controls when to start them. This independent process is xinetd

The system 1 control startup service is also a self-startup service, but the controlled service will be started if it is not turned on

A few important directories

/ etc init. d / : all service startup scripts place (learning shell script syntax place)
/etc/sysconfig/(initialization environment profile for each service)
etc/ xined.conf unified 1 controls the overall configuration file for the startup service
/ etc xined. d/series 1 control to start the service configuration file (configuration file for each service)
/etc/: the respective configuration files of the self-starting services
/var/lib/ respective configuration files for the bootup service
/var/run/: the PID record office of the program for each service


Related articles: