Tuesday, February 14, 2017

Fedora Commands

  • Linux version
    • uname -a
  • HDD capacity
    • df -h
  • Memory
    • free -m
  • Hostname
    • vi /etc/hostname
    • hostname -F /etc/hostname
  • Shell
    • cat /etc/shells
    • echo $SHELL
    • chsh: permanently change shell for user
  • Prompt
    • export PS1="[\\u@\\h:\\w:]\\$ "
  • Size of a directory
    • du -sh .
  • User
    • useradd userid -d <home-dir>
    • passwd userid
    • userdel -r userid
    • /etc/sudoers: add "user_id ALL=(ALL) NOPASSWD: ALL"
      • dnf install sudo
    • id username
  • Reset profile
    • dracut --regenerate-all --force
    • sync 
  • Extend the HDD
    • lvextend -l +100%FREE /dev/mapper/fedora-root
    • resize2fs /dev/mapper/fedora-root
  • Disk image backup & restore: disks and gparted
  • Manage start applications
    • by gnome-tweak-tool (can be installed in Software)
  • Manage services
    • systemctl status smb.service
  • To show gateway
    • ip route show
  • nis
    • stop & disable firewalld.service
    • edit /etc/sysconfig/selinux to disabled 
    • dnf install ypbind rpcbind
    • /etc/nfsmount.conf
      • Defaultvers=3
    • ypdomainname hq.k.grp
    • /etc/sysconfig/authconfig
      • USENIS=yes
    • /etc/yp.conf
      • domain hq.k.grp server 10.4.50.16
      • domain hq.k.grp server 10.4.50.17
    • /etc/nsswitch.conf
      • passwd: add nis
      • shadow: comment out
      • group: add nis
      • netgroup: nis sss
      • automount: files nis sss
    • systemctl enable rpcbind ypbind and reboot
  • autofs
    • dnf install autofs
    • /etc/sysconfig/autofs
      • BROWSE_MODE="yes"
    • /etc/auto.master
      • auto.master.mtvlnx
    • /etc/resolv.conf
      • search hq.k.grp
      • nameserver 10.4.40.7
      • nameserver 10.4.20.46
    • systemctl enable & start autofs.service
  • nfs
    • NFS mount
      • create /mnt/platform
      • mount -t nfs 10.73.1.118:/platform /mnt/platform
      • vi /etc/fstab
        • 10.73.1.118:/platform /mnt/platform nfs defaults 0 0
      • With username, password
        • mount -t cifs -o username=username,password=password //10.4.38.58/stormtest/flash/build /mnt/stormtest
      • vi /etc/fstab
        • //10.4.38.58/stormtest/flash/build /mnt/stormtest cifs username=username,password=password 0 0
    • NFS export
      • /etc/exports
      • /home/yjpark *(rw,no_root_squash)
      • systemctl start rpcbind nfs-server
  • samba
    • yum install samba
    • system-config-samba or
    • vi /etc/samba/smb.conf
     [global]
     workgroup = HQ
     server string = yjpark_linux
          security = user 

          [homes]
          comment = Home Directories
          valid users = %S, %D%w%S
          browseable = Yes
          writable = yes
          inherit acls = Yes


     [yjpark] => doesn't seem to need it
     comment = Yongjin's linux PC
     path = /local/yjpark
     public = yes
     writable = yes
          browseable = Yes

    • service smb restart
    • smbpasswd -a yjpark
    • firewall-cmd --permanent --add-service=samba
    • service firewalld restart
  • http
    • systemctl enable/start httpd.service
  • telnet
    • yum install telnet-server
    • systemctl start telnet.socket or systemctl enable telnet.socket
    • firewall-cmd --permanent --add-service=telnet
    • service firewalld restart
  • ftp
    • yum install vsftpd
    • /etc/vsftpd/vsftpd.conf
         local_enable=yes
    • service vsftpd start
  • tftp
    • dnf install tftp-server
    • systemctl enable & start tftp.socket
    • cd /; ln -s /var/lib/tftpboot
    • change home: /lib/systemd/system/tftp.service
  • libs
    • dnf
      • sudo, procps, passwd, python-devel, libxslt-devel, libxml2-devel, redhat-rpm-config, python-pip, pandoc, nodejs, npm, daemonize, libXScrnSaver, libXScrnSaver-devel, GConf2, fontconfig, cairo, cairo-devel, cairomm-devel, libjpeg-turbo-devel, pango, pango-devel, pangomm, pangomm-devel, giflib-devel, libXi, libXcursor
    • pip
      • --upgrade pip, lxml, beautifulsoup4, junit_xml
    • npm
      • npm@latest -g, selenium-webdriver -g, selenium-webdriver (as localadmin)
  • OTV5-CI docker node setup:
    • create /home/jk for localadmin:localadmin
    • cp /users/yjpark/p4/p4 to /usr/local/bin
    • dnf update
    • dnf install docker, enable & start
    • docker load -i /users/yjpark/docker/*
    • pip install --upgrade pip, lxml, bs4, junit_xml
  • firewall
    • firewall-cmd --add-port=80/tcp --permanent
    • firewall-cmd --reload
    • service firewalld stop
  • query service ports
    • vi /etc/services
    • or sudo nmap -sT -O localhost
    • or netstat -anp
  • Apach2
    • dnf install httpd
    • version: httpd -v
    • systemctl start httpd.service
    • default index file: touch /var/www/html/index.html
  • PHP
    • dnf install php
    • image handling module: dnf install php-gd
    • multi language: dnf install php-mbstring
  • MySQL
    • dnf install mariadb
    • dnf install mariadb-server
    • systemcdtl start mariadb.service
    • /usr/bin/mysql_secure_installation
      • Setup root password, etc
    • dnf install php-mysql (FC24)
    • dnf install php-pdo_mysql (FC25)
    • dnf install MySQL-python
    • vi /etc/my.cnf
         [mysqld]
                :
         character-set-server = utf8mb4
         collation-server = utf8mb4_unicode_ci
    • systemctl restart mariadb.service
    • mkdir www
    • exit
  • phpMyAdmin
    • dnf install phpmyadmin
    • vi /etc/httpd/conf.d/phpMyAdmin.conf
   AddDefaultCharset UTF-8

   <IfModule mod_authz_core.c>
     # Apache 2.4
     <RequireAny>
       #ADD following line:
       Require all granted
       Require ip 127.0.0.1
       Require ip ::1
     </RequireAny>
   </IfModule>
   <IfModule !mod_authz_core.c>
     # Apache 2.2
     #CHANGE following 2 lines:
     Order Allow,Deny
     Allow from All
     Allow from 127.0.0.1
     Allow from ::1
   </IfModule>
</Directory>



  • ffmpeg
    • rpm -Uvh http://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-stable.noarch.rpm http://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-stable.noarch.rpm
    • In case need GPG key:
      • https://rpmfusion.org/keys?action=AttachFile&do=view&target=RPM-GPG-KEY-rpmfusion-free-fedora-20
      • sudo rpm --import key_above
    • dnf install ffmpeg
  • nginx
    • dnf install nginx
    • systemctl enable nginx
    • vi /etc/nginx/nginx.conf:
          listen 8090 default_server;
          root /home/yjpark/www
    • semanage port -l | grep http_port_t
    • semanage port -a -t http_port_t -p tcp 8090
    • systemctl start nginx
    • getenforce
    • setenforce Permissive
    • systemctl stop nginx; systemctl start nginx
    • chcon -Rt httpd_sys_content_t /home/yjpark/perforce/workspace/www/nginx
  • nginx: install from source
    • openssl:
      • wget http://www.openssl.org/source/openssl-1.0.2f.tar.gz
      • cd openssl-1.0.2f
      • ./Configure linux-x86_64 --prefix=/usr
      • make; sudo make install
    • pcre
      • wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.40.tar.gz
      • ./configure; make; sudo make install
    • wget http://zlib.net/zlib-1.2.11.tar.gz
      • ./configure; make; sudo make install
    • download https://github.com/arut/nginx-rtmp-module
    • wget http://nginx.org/download/nginx-1.11.9.tar.gz
      • ./configure --add-module=../nginx-rtmp-module-master --with-http_ssl_module
      • make; sudo make install
    •   mkdir /tmp/HLS/cam
    • In /usr/local/nginx/conf/nginx.conf:

rtmp {

    server {

        listen 1935;

        allow play all;



        chunk_size 4000;



        # video on demand for flv files

        application cam {

            allow play all;

            live on;

            hls on;

            hls_nested on;

            hls_path /tmp/HLS/cam;

            hls_fragment 10s;

            exec_static ffmpeg -i rtmps://stream-delta.dropcam.com/nexus/a203d89605a4454a94caed1b16024f79 -c:v libx264 -an -f flv rtmp://localhost:1935/cam/nest;
            exec_static ffmpeg -i rtmps://stream-delta.dropcam.com/nexus/a203d89605a4454a94caed1b16024f79 -g 1 -s 320x240 -vcodec libx264 -vprofile baseline -acodec libmp3lame -ar 44100 -ac 1 -f flv rtmp://localhost:1935/cam/nest;

        }



        # video on demand for mp4 files

        application vod {

            allow play all;

            play /home/yjpark/www/nginx/mp4s;

        }



        application hls {

            live on;

            hls on;

            hls_path /tmp/HLS;

        }



    }

}



http {

    include       mime.types;

    default_type  application/octet-stream;



    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '

    #                  '$status $body_bytes_sent "$http_referer" '

    #                  '"$http_user_agent" "$http_x_forwarded_for"';

    #access_log  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;

    server {
        listen       8090;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root /home/yjpark/www/nginx/html;
            index index.html index.htm;
        }

        #creates the http-location for our full-resolution (desktop) HLS stream - "http://my-ip/cam/nest/index.m3u8"
        location /cam {
            types {
                application/vnd.apple.mpegurl m3u8;
                video/mp2t ts;
            }
            alias /tmp/HLS/cam;
            add_header Cache-Control no-cache;
        }

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}
        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        #location ~ \.php$ {
        #    root           html;
        #    fastcgi_pass   127.0.0.1:9000;
        #    fastcgi_index  index.php;
        #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
        #    include        fastcgi_params;
        #}

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #    deny  all;
        #}
    }
}

    • sudo /usr/local/nginx/sbin/nginx -s stop;  sudo /usr/local/nginx/sbin/nginx
  • Server/client certificates
    • http://theheat.dk/blog/?p=1023
    • https://engineering.circle.com/https-authorized-certs-with-node-js-315e548354a2
  • Perforce
    • Download p4d from https://www.perforce.com/downloads/helix-versioning-engine-p4d
    • vi /etc/systemd/system/p4d.service
      • # Example Perforce systemd file (p4d.service):
        #
        # This service file will start Perforce at boot, and
        # provide everything needed to use systemctl to control
        # the Perforce server process.
        
        [Unit]
        # Note that descriptions are limited to 80 characters:
        Description=Perforce Server
        
        # Starts Perforce only after the network services are 
        # ready:
        #After=network.target
        After=network-online.target
        
        [Service]
        # The type should always be set to "forking" to support
        # multiple Perforce processes:
        Type=forking
        
        # Set the system user used to launch this process (usually
        # 'perforce':
        User=perforce
        
        # The command used to start Perforce:
        ExecStart=/usr/bin/p4d -r /home/yjpark/p4d/p4d -p 10.0.0.211:1666 -d
        
        [Install]
        # Describes the target for this service -- this will always
        # be 'multi-user.target':
        WantedBy=multi-user.target
      • service start p4d
      • service enable p4d
        • a symbolic link to p4d.service file will be created in /etc/systemd/system/multi-user.target.wants
    • Download p4v from https://www.perforce.com/downloads/helix-visual-client-p4v
  • dual boot order
    • /etc/default/grub
    • change GRUB_DEFAULT=<number>
    • grub2-mkconfig -o /boot/grub2/grub.cfg
  •   Nomachine for Fedora 26+
    • Until we add support for Wayland protocol you should disable Wayland in the gdm configuration by adding the following key in /etc/gdm/custom.conf:
    • WaylandEnable=false