您的位置:首页 > 运维架构 > Linux

linux 常用操作及其命令

2014-08-18 07:55 387 查看
虚拟机安装centeros  参照:http://www.cnblogs.com/zhcncn/p/4071539.html

网络

iptables:

<span style="font-size:9pt">iptables 所在目录 /etc/sysconfig/iptables</span>
service iptables status 查看iptables状态
service iptables restart iptables服务重启
service iptables stop iptables服务禁用
</pre><pre name="code" class="reply-text mb10" id="content-662957502"><strong>权限</strong>
</pre><pre name="code" class="reply-text mb10" id="content-662957502">1.为普通用户添加sudo权限。1.1 chmod u+x /etc/sudo<span style="font-family:Arial, Helvetica, sans-serif;">ers  1.2  添加: youuser            ALL=(ALL)                ALL   </span><span style="font-family: Arial, Helvetica, sans-serif;">1.3 chmod u-x /etc/sudo</span><span style="font-family: Arial, Helvetica, sans-serif;">ers</span>
</pre><pre name="code" class="reply-text mb10" id="content-662957502">
<strong>文件</strong>
<pre id="best-content-505107552" accuse="aContent" class="best-text mb-10" style="margin-top: 0px; margin-bottom: 10px; padding: 0px; font-family: arial, 'courier new', courier, 宋体, monospace, 'Microsoft YaHei'; white-space: pre-wrap; word-wrap: break-word; font-size: 14px; color: rgb(51, 51, 51); line-height: 24px; background-color: rgb(243, 255, 236);">1、*.tar 用 tar –xvf 解压
2、*.gz 用 gzip -d或者gunzip 解压
3、*.tar.gz和*.tgz 用 tar –xzf 解压
4、*.bz2 用 bzip2 -d或者用bunzip2 解压
5、*.tar.bz2用tar –xjf 解压
6、*.Z 用 uncompress 解压
7、*.tar.Z 用tar –xZf 解压
8、*.rar 用 unrar e解压
9、*.zip 用 unzip 解压
</pre><pre name="code" class="reply-text mb10" id="content-662957502"><strong>系统</strong>

有的时候profile文件被破坏,bash路径找不到 , export PATH=/usr/bin:/usr/sbin:/bin:/sbin:/usr/X11R6/bin 临时设置。

修改环境变量 /etc/profile  修改完毕 source /etc/profile 保存生效。

export NODE_HOME=/opt/tools/nodejs/node_home

export PATH=$NODE_HOME/bin:$PATH

编辑/etc/sudoers文件。也就是输入命令"vim /etc/sudoers",进入编辑模式,找到这一 行:"root ALL=(ALL) ALL"在起下面添加"xxx
ALL=(ALL) ALL"(这里的xxx是你的用户名),然后保存退出。

# 总核数 = 物理CPU个数 X 每颗物理CPU的核数
# 总逻辑CPU数 = 物理CPU个数 X 每颗物理CPU的核数 X 超线程数

# 查看物理CPU个数
cat /proc/cpuinfo| grep "physical id"| sort| uniq| wc -l

# 查看每个物理CPU中core的个数(即核数)
cat /proc/cpuinfo| grep "cpu cores"| uniq

# 查看逻辑CPU的个数
cat /proc/cpuinfo| grep "processor"| wc -l

cpu  top 看进程和cpu的使用率
uptime 看cpu负载
内存 free   看内存呢虚拟内存 -m 是以兆为单位显示
硬盘 df -hT 查看个各个分区的使用情况,-h是以G为单位显示  -T是显示分区的系统类型
iostat -x  可以查看磁盘的IO信息

查看网卡信息
ethtool eth0


yum 只下载rpm包 不安装:

yum install --downloadonly --downloaddir=/tmp <package-name>
rpm -ivh --relocate /=/opt/temp xxx.rpm;
以prefix进行安装:
rpm -ivh --prefix= /opt/temp  xxx.rpm


                                            
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: