Friday, November 13, 2015

How to create the yum repository

Why do we need to create repository?

The purpose of creating a repository is we wants to install offline. If we don't have an internet connection to external, we unable to download package by yum command. This time we can used local repository, in other word, yum install package from local disk. We have to mount it first, and used yum command it will automatic download from the mount place.

Overall it 's a offline install package. I have provided RHEL 6 and RHEL 7.

------------------------------------RHEL7---------------------------------------


1)Create the new directory and mount the RHEL 7 DVD.
# mkdir /rhel7-repo/ 
# mount /dev/cdrom /rhel7-repo/  
# cd  /rhel7-repo/


2)Navigate to /etc/yum.repos.d/ directory.

3) Create a new file with below contents with extension of “.repo” .


# cat unixarena-rhel7.repo
[rhel7_dvd]
gpgcheck = 0
enabled = 1
baseurl = file:///rhel7-repo
name = unixarena-repo

4) After Modify the file, please yum clean it
[root@UnixArena-RHEL7 yum.repos.d]# yum clean all
Loaded plugins: langpacks, product-id, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Cleaning repos: rhel7_dvd
Cleaning up everything

5)Done

reference: http://www.unixarena.com/2015/04/how-to-create-the-yum-repository-on-rhel-7.html


------------------------------------RHEL6---------------------------------------


1)Create the new directory and mount the RHEL 7 DVD.

# mkdir /dvd/ 
# mount -0 loop /dev/cdrom /dvd
# cd  /dvd/

2)Create a file broexperts.repo  with the following content:
[broexperts]
mediaid=XXXXXX.XXXX   ==> look for mediaid (.diskinfo located in DVD)
name=Local Media Repo
baseurl=file:///dvd/
enabled=1
gpgcheck=0

Find what is our mediaid
#cd /dvd/
#cat .discinfo
xxxxxx.xxx
Red Hat Enterprise Linux 6.0
i386
1
Modify broexperts.repo
# vi /etc/yum.repos.d/broexperts.repo
[broexperts]
mediaid=XXXXXXX.XXXX
name=Local Media Repo
baseurl=file:///dvd/
enabled=1
gpgcheck=0
3. save and exit
reference: https://www.youtube.com/watch?v=NrwDVccKuKw

------------------------------------Let try to see if it work or not---------------------------------------


 yum install httpd

Wednesday, August 26, 2015

DRAC Tools[Dell Sol]

DRAC Tools[Dell Sol]
Dell can used other tool called DRAC.

Tool download as below link:
http://www.dell.com/support/home/us/en/ussoho1/Drivers/DriversDetails?driverid=hr1v5

Open cmd prompt under window and this command can used:

racadm getconfig -g cfgUserAdmin -i 2
racadm config -g cfgUserAdmin -o cfgUserAdminPassword -i 1 newpassword

[by Ip address]
racadm -u root -p calvin -r 192.168.1.1 config -g cfgUserAdmin -o cfgUserAdminPassword -i 1 password

Tuesday, August 25, 2015

SSH

Setup  SSH

SSH is a remote shell prompt that you can access and remote to linux server. You can use tera team, putty or related tool.

Note: Rhel/Centos ssh default is install, you don;t have to open manual.

ubuntu install ssh==>sudo apt-get install sshserver




Samba

Set up SAMBA server (linux 網路芳鄰分享出來,window 才可以用)

Samba server is like share folder to window. IN other means, window will be able to access to folder, can read or write, according to what you set.

Ubuntu: 
don't need to enter password
# vi /etc/samba/smb.conf

# ----------------------- Standalone Server Options ------------------------
security = user
guest account = nobody
map to guest = Bad User
passdb backend = tdbsam

unix charset = utf8
dos charset = cp950

#============================ Share Definitions ==============================
[GUEST]
  path = /home
  #writable = yes
  read only = yes
  browseable = yes
  guest ok = yes
  guest only = yes
  public = yes

need to enter password
# --------------------------- Logging Options -----------------------------
unix charset    = utf8
display charset = utf8
dos charset     = cp950
# ----------------------- Standalone Server Options ------------------------
security = user
passdb backend = tdbsam
#============================ Share Definitions ==============================
[samba]
        comment = Root Directories
        path = /
        browseable = yes
        writable = yes


Redhat6.X/centos6.X/Fedora





Monday, August 24, 2015

Linux command (system, advance)

Linux command (system, advance)

Disk/ storage part:

dd command: used to back up disk or partition, most often used for backup file, like ghost
dd if=/'name of the iso file name[to]' of='/backup partition[from]'
ex: dd if =/filename.iso of /dev/sdd
 or
dd if =/dev/sfa of=/dev/sdd

df command: see the size of the hdd 
#df -h
#df


extract and compress file:
extract file
tar -xzf zzz.tar.gz

compress file 'file '
tar -tzvf compressed.tar.gz


Dhcp setup

Dhcp setup (RHel 6.X , Centos, Ubuntu)

1)Modify configure file as below, to which mac and ip address you wants to set:
修改configure file,把mac和ip 改就會自動指定。

[root@pxeserver /]# vi /etc/dhcp/dhcpd.conf
#P Server Configuration file.
#   see /usr/share/doc/dhcp*/dhcpd.conf.sample
#   see 'man 5 dhcpd.conf'

#


default-lease-time 4320000;
#default-lease-time 7200;
max-lease-time 8640000;
#max-lease-time 21600;

log-facility local7;
subnet 192.168.2.0 netmask 255.255.255.0 {
  #range 192.168.2.101 192.168.2.200;
  option subnet-mask 255.255.255.0;
}


host RUT name {
  hardware ethernet XX:XX:XX:XX:XX:XX;
  fixed-address 192.168.2.100;
}

2)restart dhcp services
[root@pxeserver /]#service dhcpd restart

Thursday, August 20, 2015

推薦好用軟體_生活好用

推薦好用軟體_生活好用

雲端應用[cloud storage relate  
[大家最常用的: ]
Dropbox
Google Drive
Asus Storage : 可以傳上去,去ibon 印東西
Pcloud: 可以分享給朋友上傳或下載


遠端連線程式[remote control tool]
Putty
Xshell 4
tera team
Moba Xterm [類似 putty]
winscp [window 可以下載或上傳到 linux,類似FTP]

雲端Terminal 可以寫不同語法
Koding 

規劃計畫圖軟體
Coogle [心智圖-collaborative mind-mapping tool ]
DrawExpress Diagram [線上製作流程圖flow chart diagram]
Draw.io [線上製作流程圖 flow chart diagram]
Mindly  [心智圖-collaborative mind-mapping tool ]
XMind 7 [軟體工程圖,UMLdigram]
reference: http://www.playpcesor.com/2014/12/coggle.html

Window 叫鍵盤

Small Keyboard on Window [小鍵盤]


Windows format command [指令格式化]

Windows format command [指令格式化]
cmd
format D: /FS:NTFS /x

Friday, March 13, 2015

Window partition/disk problem command

Setup was unable to create a new system partition. [安裝過程無法刪除partition]


Sometimes, when install OS, system had detect HDD, but is unable to delete or inital partition, so we have to delete manual by these step: 
(SHIFT+F10) to get a CMD window
or by repair your computer as below picture to enter to cmd prompt














DiskPart <ENTER>
list disk <ENTER>
select disk 0 <ENTER>
clean <ENTER>
create partition primary align=1024 <ENTER>
format fs=ntfs <ENTER> (Will Take a While)
assign <ENTER>
active <ENTER>
exit <ENTER>
exit <ENTER> 


BMC Command (ipmitool command)

Thais are command of ipmi using bmc, will commonly used. .
Command is able to work fdor local and remote.
If occur ipmitool sel ==>means local, if command no ip means local. .
If occur ipmitool -H 192.168.2.1 ==>means remote

Command
1) Show SEL
ipmitool sel

2) show BMC ip information
ipmitool lan print

3) reset bmc ip
ipmitool raw 06 02

4)set bmc ip to static and set ip address
ipmitool lan set 1 ipsrc static
ipmitool lan set 1 ipaddr 192.168.2.1

5)power consumption( power on, off, reboot)
ipmitool -H 'ip address'  -U USERID -P PASSW0RD -I lanplus chassis  [power off| power on |reset]

example:
ipmitool -H 192.168.2.1 -U USERID -P PASSW0RD -I lanplus chassis  power off
ipmitool -H 192.168.2.1 -U USERID -P PASSW0RD -I lanplus chassis  power on
ipmitool -H 192.168.2.1 -U USERID -P PASSW0RD -I lanplus chassis  power reset
ipmitool -H 192.168.2.1 -U USERID -P PASSW0RD -I lanplus chassis  power status

6)show sensor
ipmitool sensor

7) fw cersion
ME: ipmitool -b 0x6 -t 0x2c raw 0x06 0x04
BMC: ipmitool mc info | grep "Firmware Revision"
CPLD: ipmitool raw 0x3c 0x58

8) fru version
ipmitool fru

IPMI RAW command

0x02 GET LAN Config
0x01 Channel Num
0x04 IP Source(Selector)
0x00 not use set Selector
0x00 not require block num
Response 指令格式 "NetFnCode CommandCode CopmpletionCode Data .."
Ex.0x0D 0x02 0x00 0x01
0x0D Response Transport Media-specific configuration & control
0x02 GET LAN Config
0x00 Command Completed Successful
0x01 IP source is Static
## NetFn code
0x00(request), 0x01(Response) Chassis
0x02(request), 0x03(Response) Bridge
0x04(request), 0x05(Response) Sensor/Event
0x06(request), 0x07(Response) Application
0x08(request), 0x09(Response) Firmware Transfer
0x0A(request), 0x0B(Response) Non-volatile storage
0x0C(request), 0x0D(Response) Transport Media-specific configuration & control
0x0E- 0x2B Reserved
2Ch-2Dh Extension Non-IPMI group
2Eh-2Fh OEM/Non-IPMI group
30h-3Fh Controllerspecific OEM/Group
## Completion Code
0x00 Command Completed Normally
0xC0 Node Busy
0xC1 Invalid Command
0xC2 Command invalid for given NetFn
0xC3 Timeout
0xC4 Storage Out of space
0xC5 Reservation Canceled or Invalid Reservation ID
0xC6 Request data truncated
0xC7 Request data length invalid
0xC8 Request data field length limit exceeded
0xC9 Parameter/Data out of range
0xCA Cannot return number of requested data bytes
0xCB Requested Sensor, data, or record not present
0xCC Invalid data field in Request
0xCD Command illegal for specified sensor or record type
0xCE Command response could not be provided
0xCF Cannot execute duplicated request
0xD0 Command response could not be provided. SDR Repository in update mode.
0xD1 Command response could not be provided. Device in firmware update mode.
0xD2 Command response could not be provided. BMC initialization or
initializationagent in progress
0xD3 Destination unavailable
0xD4 Cannot execute command due to insufficient privilege level or other
securitybased restriction
0xD5 Cannot execute command. Command or parameter not supported in present
state
0xD6 Cannot execute command. Parameter is illegal
0xFF Unspecified error
0x01-0x7E OEM completion codes
0x80-0xBE Standard command-specific codes
0x7F, 0xBF, 0xD7-0xFE Reserved


Wednesday, February 25, 2015

RAMDISK

linux command (network)

Add Network (network command)

(1)add interface
[root@server ~]#cd /etc/sysconfig/network-scripts
[root@server ~]#vi ifcfg-eth0
DEVICE="eth2"
BOOTPROTO="dhcp"
HWADDR="00:02:C9:27:59:FE"
NM_CONTROLLED="yes"
ONBOOT="yes"
TYPE="Ethernet"
IPV6INIT="no"

(2)If set ip, will not active after reboot.
When we set some ip address, after reboot or services restart will not active. This means that we have to kill the temporary store ip address. This often occur when we had a dhcp Ip address, then we wants to change to a static. But i also found out that if i wants to change a new network card, will also happen, the ip will not change.

Please set ip address first, then clear this.
[root@server ~]#cd /etc/udev/rules.d
[root@server ~]#rm 70-persistent-net.rules

(3) show ip address
[root@server ~]#ifconfig

(4) show ip interface
[root@server ~]#ip a












(5) ethtool - query or control network driver and hardware settings
ethtool ethernet interface
#ethtool eth0
This will let you see your link rate, support wake on lan, lan detect or not, and so on.

(6) enable your interface
#ifdown eth0
#ifup eth0

(7) ping
ping ip address
ping -c 1 ipaddress  ==>ping one second

(8) Search dhcp client ip address, or bmc ip address
cat /var/log/messages | grep BMC MAC address
example: cat /var/log/messages | grep  xx:xx:xx:xx:xx:xx

(9) changed Server name 
vi /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=putXX




Linux command

PART 1 SIMPLE COMMAND

(1) list directory contents (refer to window dir)
command: ls
Description /purpose: Print or list the file or folder in this directory

[root@server ~]# ls

command: ll
Description /purpose:  Print or list the file or folder in this directory, but this will show information.
[root@server ~]# ll













(2) print name of current/working directory (pwd)
Description /purpose: show which directory or path you are in right now.
[root@server ~]# pwd
/root

(3) copy (cp)
Description /purpose: copy file or create backup

#cp dhcp.conf dhcp.conf.bk

(4)move or rename file ( mv)
Description /purpose:  rename a file name, or generate a file
#mv old.txt new.txt

(5) cat
Description /purpose: read a file name
cat 123.txt

(6)modify text (vi or vim)
Description /purpose: to modify some file
vi is modify, and vim is improve, which will have show in different color.
Some variable need to used

vi











vim

:q! ==>exit without saving
:w! ==>save
:wq!==>save and quit
:x!==>save and exit
? or / ==>search

Note: For more information, please refer shell script



(7) touch
Description /purpose:to generate a file. Different between vi is it don't have to save to generate a file. It will generate a file if input touch command.
touch aaa.txt

(8)tail
Description /purpose: output the last part of files
will print last 10 line 
#tail /var/log/message

 output appended data as the file grows. 
#tail -f

difference from cat versus tail
tail is different from cat, is cat will read all the file once, but tail will not. For example if you have a log file, you cat log file, it will read all the line from first line to last line. But tail will read last line, and if the file still have message, it will also show.

 (9) clear
Description /purpose:clear the terminal screen
#clear


PART 2 Intermediate (common used and file related)

1. extract file
tar -zxvf extract.tar.gz
#tar -zxvf filename.tar.gz 

2. compress file
tar -tzvf compressed.tar.gz
tar -zcvf filnename.tar.gz 'folder destination/'
#tar -zcvf filnename.tar.gz folder /test

3. mount
what is mount?
A mount is where I wants to mount a directory into one folder. Mount this command can used for many ways.
Basely mount this command is like if i have a directory names test, if i wants to mount a directory "dhcp" into test this directory. Directory test all the data will be used by dhcp this directory. In other word mean all test directory will be gone, will only appear dhcp data. If you umount it, it will be appear.

Mount this command can be used for:

Mount for folder to folder which is like shortcut
# mount --bind /etc/dhcp /dhcpfile_test











Mount for usb drive to /mnt directory 




Mount for network 



4 link or shortcut
command "ln -s"
ln -s orginally folder or file shortcut
# ln -s /etc/dhcp/ /dhcpfile











5 set date
date MMddhhmmyyyy




BATCH(.bat) SCRIPT(window)

PART1 SIMPLE

(1)CREATE FOLDER

set /P id=Enter id:
mkdir %id%

(2) FOLDER NAME WITH DATE
for /F "tokens=1-4 delims=/ " %%A in ('date/t') do (
set DateDay=%%A
set DateMonth=%%B
set DateYear=%%C
)

set CurrentDate=%DateMonth%-%DateDay%-%DateYear%

mkdir %CurrentDate% 

(3) PING 
@echo off
set /p a="Enter IP Address or Name: "
ping %a%
pause

(4)


PART2 Mixed function script
(1) user enter Devices name and IP address

@echo off
for /F "tokens=1-4 delims=/ " %%A in ('date/t') do (
set DateDay=%%A
set DateMonth=%%B
set DateYear=%%C
)


set CurrentDate=%DateDay%-%DateMonth%-%DateYear%
set /P name=Enter name of folder:
set /p bmc_ip="Enter BMC IP Address: "


mkdir %CurrentDate%_%name%

@echo on
ipmitool -I lan -H %bmc_ip% -U USERID -P PASSW0RD sensor >  %CurrentDate%_%name%/SENSOR.TXT
ipmitool -I lan -H %bmc_ip% -U USERID -P PASSW0RD sel list >  %CurrentDate%_%name%/list.TXT
ipmitool -I lan -H %bmc_ip% -U USERID -P PASSW0RD sel elist > %CurrentDate%_%name%/elist.TXT


output:
Enter name of folder: DUT1-1
Enter BMC IP Address: 192.168.1.2