In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-03 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
echo
The echo command is used to print the value of a shell variable in the shell, or to output a specified string directly.
syntax
echo(option)(parameter)
option
-e: Activates escape characters.
When the-e option is used, the following characters appear in the string and are treated specifically rather than output as normal text:
\a sound a warning;
\b Delete the previous character;
\c No newline at the end;
\f New line but cursor remains in original position;
\nNew line and cursor moved to the beginning of the line;
\r Cursor moves to the beginning of a line without newline;
\tInsert tab;
\v is the same as\f;
\insert\character;
\nnn Insert ASCII characters represented by nnn (octal);
examples
echo "hello world" Display normal strings
[root@localhost ~]# echo "hello world"
"hello world"
echo -n "hello world": -n not newline
[root@localhost ~]# echo -n "hello world"
"hello world"[root@localhost ~]#
echo -e "hello \nworld":\nnewline
[root@localhost ~]#echo -e "hello \nworld"
hello
world
echo -e "hello \tworld":\thorizontal tab
[root@localhost ~]# echo -e "hello \tworld"
hello world
echo -e "hello \bworld" \bBackspace
[root@localhost ~]# echo -e "hello \bworld"
screen command
I. Screen command
Screen is free software developed by the GNU Project for command line terminal switching. Users can connect to multiple local or remote command-line sessions simultaneously and switch freely between them. GNU Screen can be thought of as the command-line interface version of the window manager. It provides a unified interface and functionality for managing multiple sessions.
1.1 Reply session
Sessions running inside Screen can be resumed as long as Screen itself is not terminated. This is especially useful for remote logged-on users--even if the network connection is lost, the user does not lose control of an open command-line session. Just log in to the host again and execute screen -r to resume the session. Also, when temporarily leaving, you can execute the detach command to suspend Screen (switch to background) while ensuring that the programs inside are running properly. This is very similar to VNC in the graphical interface.
1.2 multi-window
In Screen, all sessions run independently, with their own numbers, inputs, outputs, and window caches. The user can switch between different windows by shortcut keys, and can freely redirect the input and output of each window. Screen implements basic text operations, such as copy and paste, and also provides a scrollbar-like function to view the history of window status. Windows can also be partitioned and named, and background window activity can be monitored. Session Sharing Screen allows one or more users to log into a session multiple times from different terminals and share all the characteristics of the session (such as seeing exactly the same output). It also provides a mechanism for window access rights, which can be password protected.
syntax
screen [-AmRvx -ls -wipe][-d ][-h ][-r ][-s ][-S ]
1.4 option
options describe
-A Resizes all windows to the current terminal size.
-d Take the specified screen job offline.
-h Specifies the number of buffer rows for the window.
-m Forces new screen jobs to be created even though screen jobs are currently in operation.
-r Resume offline screen jobs.
-R tries to resume offline jobs first. If no offline jobs are found, a new screen job is created.
-s Specifies the shell to execute when creating a new window.
-S Specifies the name of the screen job.
-v Displays version information.
-x Restore screen jobs that were previously offline.
-ls or-list Displays all current screen jobs.
-wipe Checks all current screen jobs and deletes screen jobs that are no longer available.
screen -S yourname -> create a new sessionscreen -ls -> list all current sessionscreen -r yourname -> return to yourname this sessionscreen -d yourname -> remotely detach (temporarily interrupt) a sessionscreen -d -r yourname -> temporarily interrupt the current session and return to yourname this session
4. Under Session, use ctrl+a(C-a)
C-a ? -> Show all key binding information C-a c -> Create a new running shell window and switch to it C-a n -> Next, switch to next window C-a p -> Previous, switch to previous window C-a 0.. 9 -> Switch to No. 0.. 9 windowCtrl+a [Space] -> Switch from window 0 to window 9 sequentially C-a C-a -> Switch between the two most recently used windows C-a x -> Lock the current window, unlock with user password C-a d -> detach, temporarily leave the current session, change the current screen session (may contain multiple windows) thrown to the background execution, and will return to the screen when the state, at this time in the screen session, each window running process (whether foreground/background) continue to execute, even logout does not affect. C-a z -> Put the current session in the background, and use the fg command of the shell to go back. C-a w -> Display all window list C-a t -> time, display current time, and system load C-a k -> kill window, forcibly close current windowC-a [ -> enter copy mode, in copy mode you can rollback, search, copy just like using vi C-b Backward, PageUp C-f Forward, PageDown H(capital) High, move cursor to upper left L Low, Move the cursor to the lower left corner 0 to the beginning of the line $to the end of the line w forward one word in words b backward one word in words Space Press the first time for the start of the marked area, press the second time for the end copy mode C-a] -> paste, paste the content just selected in copy mode
create session
screen -dmS session_name
Show all sessions
screen -ls
Forcing a session to close
screen -S pid -X quit
screen -S 7927 -X quit
date command
date
date
The date command displays or sets the system time and date.
A lot of shell scripts need to print time or date in different formats and perform actions based on time and date. Latency is usually used to provide a waiting period during script execution. Dates can be printed in a variety of formats, or fixed formats can be set using the command. In UNIX-like systems, the date is stored as an integer, the size of which is the number of seconds that have elapsed since January 1, 1970, at 0:00:00 UTC.
syntax
date(option)(parameter)
option
-d: Displays the date and time to which the string refers. String must be surrounded by double quotes;
-s: Sets the date and time based on a string. String must be surrounded by double quotes;
-u: Display GMT;
--help: online help;
--version: Displays version information.
parameters
: Specifies the datetime format to use when displaying.
List of date format strings
%H hour, 24 hour system (00~23) %I hour, 12 hour system (01~12) %k hour, 24 hour system (0~23) %l hour, 12 hour system (1~12) %M minute (00~59) %p AM or PM%r time displayed, 12 hour system (hh:mm:ss %p) %s Seconds elapsed since January 1, 1970 00:00: 00% S Display seconds (00~59) %T Display time, 24 hour clock (hh:mm:ss) %X Format of time display ( %H:%M:%S) %Z Display Time Zone, Date Field (CST) %a Short Form of Week (Sun~Sat) %A Full Form of Week (Sunday~Saturday) %h,%b Short name of month (Jan~Dec) %B Full name of month (January~December) %c Date and time (Tue Nov 20 14:12:58 2012) %d Day of month (01~31) %x,%D Date (mm/dd/yy) %j Day of year (001~366) %m Month (01~12) %w Day of week (0 for Sunday) %W Week of year (00~53, Monday is the first day) %y Last two digits of year (99 for 1999) %Y Show full year
Output without parameters
[root@localhost ~]# date
Mon Mar 5 09:44:58 CST 2018
formatted output
[root@localhost ~]# date +"%y-%m-%d"
18-03-05
Output yesterday date
[root@localhost ~]# date -d "1 day ago" +"%y-%m-%d"
18-03-04
common format conversion
[root@localhost ~]# date -d "2018-3-4" +"%Y-%m-%d %H:%M:%S"
2018-03-04 00:00:00
date +%Y%m%d //Display the day before yesterday
set time
date -s //Set the current time. Only root permission can set it. Others can only view date -s 20120523 //Set it to 20120523. This will set the specific time to null 00:00:00 date -s 01:01:01 2012-05-23//Set the specific time without changing the date. Date -s "01:01:01 20120523"//This will set all time date-s "2012-05-23 01:01:01" //This will set all time date-s "20120523 01:01:01"//This will set all time
[root@localhost ~]# date -s "2018-3-5 12:12:12"
Mon Mar 5 12:12:12 CST 2018
1.date local2.hwclock--show //View hardware time3. If hardware time is incorrect, modify hardware time4. hwclock--set --date '2016-01-08 15:15:15' //Set hardware time5. hwclock--hctosys //Set system time and hardware time synchronization 6.clock -w //Save clock
ifconfig
ifconfig How to configure network ports:
The ifconfig tool configures the network interface through the parameters of the instruction to achieve the goal, we only say the most commonly used parameters;
ifconfig network port IP address hw MAC address netmask mask address broadcast address [up/down]
Configure the IP address of the NIC
ifconfig eth0 192.168.0.1 netmask 255.255.255.0
Configure eth0 with an IP address of 192.168.0.1 and a 24-bit mask. What if I want to configure an IP address of 192.168.1.1/24 on eth0? with the following command
ifconfig eth0:0 192.168.1.1 netmask 255.255.255.0
At this time, use the ifconifg command to view, you can see the information of the two network cards, respectively: eth0 and eth0:0. If you still want to add IP, the name of the network card will be: eth0:1, eth0:2... Fill out as many as you want. ok!
export
-f: represents the function name in [variable name].
-n: Delete the specified variable. It is not actually deleted, but it is not output to the execution environment of subsequent instructions.
-p: Lists all environment variables assigned to the program by the shell.
export -p //List the current environment variable values
export MYENV //Define environment variables
export JAVA_HOME
Defining environment variable assignments
export JAVA_HOME=valueexport JAVA_HOME=/home/duhui/java/jdk1.8.0_191
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.