2016年3月7日 星期一

CentOS - Basic Command

  •  Add user
    Issue the useradd command to create a locked user account:
    useradd <username>

    Unlock the account by issuing the passwd command to assign a password and set password aging guidelines:
    passwd <username>
     
  • Rename a folder
    mv /home/user/oldname /home/user/newname

     
  • Mount
  1. get root
  2. mkdir /mnt/iso
  3.  mount -t iso9660 -o loop /home/tecmint/Fedora-18-i386-DVD.iso /mnt/iso/
  4. cd /mnt/iso
  5. ls -l
  • Unmount
  1. umount /mnt/iso
  • t : This argument is used to indicate the given filesystem type.
  • ISO 9660 : It describes standard and default filesystem structure to be used on CD/DVD ROMs.
  • -o : Options are necessary with a -o argument followed by a separated comma string of options.
  • loop: The loop device is a pseudo-device that often used for mounting CD/DVD ISO image and makes those files accessible as a block device.
 
  • Open PDF file
xdg-open install_guide.pdf
  • Change password
  1. must login as root user 
  2.  $ passwd (user's id)
  • Change sudo file
  • http://www.liquidweb.com/kb/how-to-add-a-user-and-grant-root-privileges-on-centos-6-5/

  • How to install gcc 

           https://www.vultr.com/docs/how-to-install-gcc-on-centos-6


  • Check hostname
         $ hostname

  • List all the user

           $ cut -d: -f1 /etc/passwd
  • VNC setting
VNC软件在Linux环境中可以使用文本模式进行配置,即可以用putty登录Linux,然后开启和关闭vnc,
在有图形界面的Terminal也可以这样配置。

这样做的好处是可以同时在putty(文本模式)和vnc(图形界面)中使用Linux,比较方便
另外,VNC会调用远程机器的GPU,而Windows的远程桌面无法启动GPU,因此当用到GPU时要用VNC(或向日葵)

具体操作如下:

1、用putty登录Linux,或在有图形界面的Linux中用Ctrl+Alt+T启动一个新的Terminal
      或者: 对于图形界面的Linux, 按CTRL+ALT+F1也可进入纯文本模式, 按CTRL+ALT+F7回到图形界面模式
2、安装VNC: 解压缩VNC安装包 (VNC-Server 通用版本就行了),然后执行 sudo ./vncinstall
3、输入license: sudo vnclicense -add license号码
4、启动VNC的Service方式(让VNC随机器一起启动,即变为Daemon守护进程):
     sudo /etc/init.d/vncserver-x11-serviced (start|stop)
     sudo update-rc.d vncserver-x11-serviced defaults
     然后重新启动计算机(sudo reboot)
5、用putty登录Linux,或在有图形界面的Linux中用Ctrl+Alt+T启动一个新的Terminal
6、测试vnc是否已成为守护进程:
      ps -A|grep "vnc"
      若有名称里包含vnc的进程出现,就证明成功了
7、启动一个VNC,可以指定编号和分辨率(能启动的个数受license的限制):
     vncserver :1 -geometry 1920x1080 (编号可以自己随便输入,分辨率要根据自己显示器的实际分辨率设置)
8、关闭一个VNC:
     vncserver -kill :X (X就是当初自己编的一个序号)     
9、实际用VNC Viewer远程访问时,输入"IP地址:编号",其中的编号就是刚才自己输入的编号,然后输入的用户名
     和密码就是linux用户名和密码(如果)

close x server
cd /tmp
ls -al
delete all .x log file