Common command records in linux work

1. Document related

    1) Use rz to upload files from the windows environment to the /home/hadoop/ directory on the linux server

cd /home/hadoop/
rz -y

     2) Use sz to download the file aaa.txt from /home/hadoop/ on the linux server to the windows

cd /home/hadoop/
sz aaa.txt

     3) File copy between two linux machines

    Copy /haome/hadoop/aaa and its subfiles on the local machine to the directory /home/hadoop/ of the machine 192.168.38.165, and you will be prompted to enter the root password.

scp -r /home/hadoop/aaa [email protected]:/home/hadoop/

    4) Batch modify file content

    Batch modify 192.168.38.171 in the file /opt/product/conf/sso.conf to 192.168.1.104

sed -i "s/192.168.38.171/192.168.1.104/g" /opt/product/conf/sso.conf

 

2.ftp related

    1) Logging in to ftp this way will then ask for the FTP username and password

ftp 192.168.191.13

     2) Log in to ftp directly with the FTP account and password

lftp ftpuser:[email protected]

     3) After logging in to FTP, upload local files to FTP

lftp ftpuser:[email protected]
put C:\Users\Lenovo\Desktop\test.txt

     4) Delete files on FTP after logging in to FTP

lftp ftpuser:[email protected]
delete test.txt

     5) After logging in to FTP, pull files from FTP to the linux server directory /home/hadoop

cd /home/hadoop
lftp ftpuser:[email protected]
get test.txt

     6) Exit FTP

lftp ftpuser:[email protected]
quit

 

3. Network related

    1) View the linux local IP

ifconfig

     2) Use the packet capture command tcpdump under linux

    Capture all packets sent to port 8881 of the local machine and all packet data sent to external machines from port 8881 of the local machine

cd /home/hadoop/
/usr/sbin/tcpdump -v -X -s 0 -i bond0  port 8881 -w data.cap

 

4. Linux timing tasks

    1. Scheduled task syntax

Minute Hour day moon Week Order
0-59 0-23 1-31 1-12 0-6 (0 means Sunday) command or shell script file

 

Special characters meaning
* Represents a number within a range of values
/ stands for "every"
- Represents from a number to a number
, separate several discrete numbers

 

    crontab command parameters:

 

[hadoop@nmsc0 log]$ crontab -help
crontab: invalid option -- h
crontab: usage error: unrecognized option
usage:  crontab [-u user] file
        crontab [-u user] [ -e | -l | -r ]
                (default operation is replace, per 1003.2)
        -e      (edit user's crontab)
        -l      (list user's crontab)
        -r      (delete user's crontab)
        -i      (prompt before deleting user's crontab)
        -s      (selinux context)
[hadoop@nmsc0 log]$
      5.oracle related 5.1oracle forgot password
sqlplus /nolog
connect / as sysdba;
connect /@plsql alias as sysdba; or connect account/password @plsql alias as sysdba;

     5.2 View the currently logged in user tablespace

select username,default_tablespace from user_users;

    5.3 Export a single table to dump

exp user/paswword@sid buffer=1024000 COMPRESS=N tables=bss_black_list,file=F:\tempt\blacklist.dmp,log=F:\tempt\blacklist.log statistics=none
  6. NFS related

 

    7. Current user timed tasks

        1) Edit the crontab -e of the current user's scheduled task

#Edit crontab service file
crontab  -e
#Then paste the following:
#Execute the script at 23:30 at night /home/hadoop/crontab/hbase_major_compact_small.sh
30 23 * * * /home/hadoop/crontab/hbase_major_compact_small.sh
#linchen 00:30 execute the script /home/hadoop/crontab/hbase_major_compact_big.sh
30 0 * * * /home/hadoop/crontab/hbase_major_compact_big.sh

    Executing the above command will generate your own crontab file under /var/spool/cron, as follows:

 

        2) View current user timed tasks crontab -l

[hadoop@nmsc0 log]$ crontab -l
30 23 * * * /home/hadoop/crontab/hbase_major_compact_small.sh
30 0 * * * /home/hadoop/crontab/hbase_major_compact_big.sh   

        3) Delete the current user timed task

 

#Delete cron service without a user
crontab -r

 

        4) Check whether the current scheduled task has been executed or check the task execution log

#1. Query method for Linux system (including Redhat, SUSE)
#Users who must have permission, such as root, can view the file /var/log/cron, you can use tail -f /var/log/cron to observe
#Because tail -f /var/log/cron only displays about the last 10 records, here use tail -20 /var/log/cron to display the last 20 records

#2. Query method for UINX system (AIX, HP-UX)
#In the /var/spool/cron/tmp file, there are tmp files of croutXXX00999, and you can see the tasks being executed by tailing these files.
#3. The mail task (Linux UNIX) has a record of the crontab execution log in the /var/spool/mail/root file.
#Use tail -f /var/spool/mail/root to view the latest crontab execution.

 

    8. System scheduled tasks

    System timing tasks are generally configured in the /etc/crontab file, which contains the following contents:

[root@nmsc0 etc]# cat /etc/crontab
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/

# run-parts
01 * * * * root run-parts /etc/cron.hourly
02 4 * * * root run-parts /etc/cron.daily
22 4 * * 0 root run-parts /etc/cron.weekly
42 4 1 * * root run-parts /etc/cron.monthly
01 1 * * * root run-parts /home/zhangyangyang/cron/day
[root@nmsc0 etc]#

 Note: The parameter "run-parts" is to execute all shell scripts in a certain file directory. If it is not added, it must be followed by the full path name of the shell script and cannot be a directory.

  A few examples of timed tasks:

#Indicates that the script is executed at 23:59 every day /home/oracle/scripts/alert_log_archive.sh
59 23 * * * /home/oracle/scripts/alert_log_archive.sh >/dev/null 2>&1

#Indicates that the script is executed every 5 minutes /home/oracle/scripts/monitoring_alert_log.sh
*/5 * * * * /home/oracle/scripts/monitoring_alert_log.sh >/dev/null 2>&1

#Send a letter to [email protected] every day from Monday to Friday at 20:00 pm
3: 0 20 * * 1-5 mail -s "**********" [email protected] < /tmp/maildata

 

10.ulimit settings

    ulimit is not the bigger the better, you can refer to http://www.cnblogs.com/zengkefu/p/5635153.html for information.

    (1) The value set by the current user ulimit of linux

ulimit -a

    (2) The maximum sum of the number of files opened by all processes in the Linux system

cat /proc/sys/fs/file-max

    (3) Real-time viewing of the number of files opened by the current user in Linux

cat /proc/sys/fs/file-nr

    (4) Inheritance relationship set by ulimit


 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326944360&siteId=291194637