blackhat1337

Untitled

Feb 8th, 2024
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.28 KB | None | 0 0
  1. BASIC COMMANDS
  2. $ ls
  3. $ mkdir Nktt
  4. $ cd Nktt
  5. $ mkdir BBI
  6. $ mkdir BCOM
  7. $ mkdir BSCIT
  8. $ ls -a
  9. $ ls -l
  10. $ cd BBI
  11. $ cat >> FY ADD DATA THEN CTRL + Z
  12. $ cat >> SY ADD DATA THEN CTRL + Z
  13. $ cat >> TY ADD DATA THEN CTRL + Z
  14. $ cd ..
  15. $ cd BCOM
  16. $ cat >> FY ADD DATA THEN CTRL + Z
  17. $ cat >> SY ADD DATA THEN CTRL + Z
  18. $ cat >> TY ADD DATA THEN CTRL + Z
  19. $ cd ..
  20. $ cd BSCIT
  21. $ cat >> FY ADD DATA THEN CTRL + Z
  22. $ cat >> SY ADD DATA THEN CTRL + Z
  23. $ cat >> TY ADD DATA THEN CTRL + Z
  24. $ ls -a
  25. $ ls -l
  26. $ ls -F
  27. $ ls -r
  28. $ ls -R
  29. $ ls -S
  30. $ ls *
  31. $ ls
  32. ---------- TOUCH USE KARNE KE LIYE
  33. $ mkdir nktt1
  34. $ cd nktt1
  35. $ touch f1 f2 f3 f4
  36. $ ls -l
  37. $ cd
  38. $ cd nkkt1
  39. $ ls
  40. $ rm f1
  41. $ rm -rf f2
  42. $rm -v f3
  43. $ ls
  44. $ rm -l f4
  45. $ ls -l
  46. $ cd
  47. $ rmdir nktt1
  48. $ ls
  49. $ mkdir nktt2
  50. $ cd nktt2
  51. $ pwd
  52. $ cat >> collegegroup ADD DATA THEN Ctrl + z
  53. $ cat collegegroup
  54. $ tac collegegroup
  55. $ head collegegroup
  56. $ tail collegegroup
  57. $ more collegegroup
  58. $ less collegegroup
  59. $ man collegegroup
  60. $ date
  61. $ cal
  62. $ who
  63. ----------------------------------------------------------ADVANCE COMMAND
  64. $ ps a
  65. $ ps u
  66. $ ps x
  67. $ ps aux | less
  68. $ ps aux | tail
  69. $ ps afx
  70. $ ps aux
  71. $ ps aux >> p1.txt
  72. $ ls
  73. $ find *p1.txt
  74. $ grep "Words_to_be_searched" f5
  75. $ jobs
  76. $ gb
  77. $ fg
  78. $ top
  79. $ Pstree
  80. ---------------------------------------------------------------------------------------------------------------------------
  81. SOFT LINK
  82. $ mkdir nktt3
  83. $ mkdir softlink
  84. $ cd nktt3
  85. $ mkdir f5
  86. $ cd f5
  87. $ mkdir f6
  88. $ cd f6
  89. $ cat >> test1
  90. Hello
  91. i am fine (ctrl + z)
  92. $ pwd (COPY PATH)
  93. $ cd
  94. $ cd softlink
  95. $ ln -s (PASTE THAT COIED PATH + /test soft)
  96. $ ls -ltr
  97. $ cat soft
  98. --------------------------------------------------
  99. HARD LINK
  100.  
  101. $ mkdir nktt4
  102. $ mkdir hardlink
  103. $ cd nktt4
  104. $ mkdir f7
  105. $ cd f7
  106. $ mkdir f8
  107. $ cd f8
  108. $ cat >> test2
  109. Hello
  110. i am fine (ctrl + z)
  111. $ pwd (COPY PATH)
  112. $ cd
  113. $ cd hardlink
  114. $ ln -s (PASTE THAT COIED PATH + /test hard)
  115. $ ls -ltr
  116. $ cat hard
  117. --------------------------------------------------------------------------------------------------------------------------
  118. CHANGE IP ADDRESS
  119.  
  120. 1) CLI
  121. $ su
  122. $ ifconfig eth1
  123. $ ifconfig eth0 192.168.0.1 netmask 255.255.255.0
  124. $ ifconfig eth1
  125.  
  126. 2) GUI
  127. $ su
  128. $ system-config-network
  129. SELECT DEVICE CONFIGURATION
  130. SELECT AUTO ETH1
  131. ENTER YOUR INFORMATION IN NETWORK CONFIGURATION
  132. CLICK ON SAVE AND QUIT
  133. $ service network restart
  134. $ ifconfig
  135.  
  136. 3) NETWORK SCIPT
  137. $ su
  138. $ vi /etc/sysconfig/network-scripts/ifcfg-eth0
  139. TYPE=Ethernet
  140. BOOTPROTO=none
  141. IPADDR=192.168.0.4
  142. NETMASK=255.255.255.0
  143.  
  144. OR OR OR OR
  145.  
  146. TYPE=Ethernet
  147. BOOTPROTO=none
  148. DEFROUTE=yes
  149. IPV4 FAILURE FATAL=yes
  150. IPV6INIT=no
  151. NAME="Auto eth1"
  152. UUID=c79f9b2d-d556-4f9c-82fe-da85155209eb
  153. ONBOOT=yes
  154. DEVICE Auto eth1
  155. NM CONTROLLED=yes
  156. USERCTL=no
  157. HWADDR=08:00:27 a3: be:84
  158. PEERDNS=yes
  159. PEERROUTES=yes
  160. LAST CONNECT-1697002323
  161. IPADDR=198.168.0.1
  162. NETMASK=255.255.255.0
  163.  
  164. $ vi /etc/sysconfig/network-scripts/ifcfg-eth0
  165.  
  166. TYPE=Ethernet
  167. BOOTPROTO=none
  168. DEFROUTE=yes
  169. IPV4 FAILURE FATAL=yes
  170. IPV6INIT=no
  171. NAME="Auto eth1"
  172. UUID=c79f9b2d-d556-4f9c-82f0-da85155209eb
  173. ONBOOT=yes
  174. DEVICE=Auto eth1
  175. NM_CONTROLLED=yes
  176. USERCTL=no
  177. HWADDR=08:00:27:33:be:84
  178. PEERDNS=yes
  179. PEERROUTES=yes
  180. LAST CONNECT=1697002323
  181. IPADDR=198.168.0.4
  182. NETMASK=255.255.255.0
  183.  
  184. $ service network start
  185. $ ifcfg
  186. --------------------------------------------------------------------------------------------------------------------------
  187. USER ADD MODIFICATION DELETION
  188.  
  189. $ su
  190. $ useradd user1
  191. $ passwd user1
  192. $ su user1
  193. $ pwd
  194. GO TO ORIGINAL USER
  195. $ su user
  196. $ useradd user2
  197. $ usermod -l user2 user3
  198. $ usermod -d /new/home/directory user3
  199. $ userdel user3
  200. CREATE A GROUP:
  201. # groupadd users
  202. DELETE A GROUP:
  203. # groupdel users
  204. ADD USER TO A GROUP:
  205. # usermod -a G users user2
  206. REMOVE USER FROM A GROUP:
  207. # usermod -G - user2
  208. $ id user2
  209. $ gid=502(user2) groups=502(user2)
  210. $ usermod -m -d /home/user2 user1
  211. $ su user1
  212. $ pwd
  213. $ su user1
  214. $ usermod -e 2023-07-20 user1
  215. GO TO PROPERTIES - ACCOUNT INFO
  216. $ usermod -g m1 user1
  217. $ id user1
  218. $ usermod -L user1
  219. $ usermod -U user1
  220. $ userdel -r user1
  221.  
  222. ---------------------------------------------------------------------------------------------------------------------
  223. NFS
  224. $ su -
  225. $ rpm -qa | grep nfs
  226. $ cd /
  227. $ cd home
  228. $ ls
  229. $ mkdir test1
  230. $ cd test1
  231. $ touch f1 f2 f3
  232. $ cat >> s1
  233. Hello World
  234. $ vi /etc/exports
  235. Insert this line :
  236. /home/test *(rw,sync)
  237. and then press:
  238. (esc) : w q
  239. (enter)
  240. $ service nfs start
  241. $ ifconfig
  242. $ showmount -e 192.168.87.172 //your ip address
  243. $ service iptables stop
  244. $ service iptables status
  245. $ chmod -R 777 /home/test1
  246. $ cd ..
  247. $ pwd
  248. $ ls
  249. $ mkdir nfsclient
  250. $ mount -t nfs 192.168.87.172:/home/test1 /home/nfsclient
  251. $ cd nfsclient
  252. $ ls -l
  253. $ ls -a
  254.  
  255. -------------------------------------------------------------------------------------------------------------------
  256. SAMBA
  257. In latest windows 10 and 11 by default SMB 1.0 is disabled and SMB client version 4 is not supported in rhel 6
  258. To Enable it :
  259. 1. Press start button and search turn windows features on or off
  260. 2. Enable this SMB 1.0 as sh\own in figure
  261. 3. Restart the pc
  262. $rpm -q samba samba-common samba-client
  263. $rpm -qa | grep samba
  264. If not installed then install using
  265. $yum install samba
  266. 3. $su -
  267. 4. $cd /
  268. 5. $mkdir myshare
  269. 6. cd /myshare
  270. 7. $touch file1
  271. [myshare]
  272. comment = any comment
  273. path = /myshare
  274. writable = yes
  275. browseable = yes
  276. $vi /etc/samba/smb.conf
  277. $testparm //to check syntactical errors
  278. $setsebool -P samba_export_all_rw on
  279. $setsebool -P samba_enable_home_dirs on
  280. $ls -ldZ /myshare //It will display default_t label which needs to be set to samba_share to enable edting system files
  281. $chcon -t samba_share_t /myshare
  282. $service iptables stop
  283. $useradd test
  284. $smbpasswd -a test
  285. Password 123
  286. $service smb start
  287. $service nmb start //To use hostname instead of ip addresses nmb package is used
  288. $smbclient -U test -L localhost //to check details of share
  289. $ip addr show or $hostname //make sure internet is connected check eth ip address
  290.  
  291. Now open cmd in windows os to test connection between rhel and windows
  292. In windows cmd
  293. Ping your rhel ip address or hostname to verify connection
  294. $ping 192.168.31.172 OR //if packets sent 4 and received 4 then successful connection is established
  295. $ping mylinuxpc //if packets sent 4 and received 4 then successful connection is established Here mylinux pc is hostname of rhel
  296. Open windows explorer and right click network and click map network drive In folder textbox enter rhel server ip address
  297. e,g \\192.168.31.172\myshare
  298. OR
  299. e,g \\mylinuxpc\myshare
  300. Enter username and password
  301. Username test
  302. Password 123
  303. ----------------------------------------------------------------------------------------------------------------------
  304. FTP
  305. $yum install vsftpd (press y and enter whenever prompted)
  306. $yum install ftp (press y and enter whenever prompted)
  307. su -
  308. rpm -qa | grep vsftpd
  309. Service vsftpd start
  310. Service vsftpd restart
  311. Service vsftpd status
  312. Service iptables stop
  313. Service iptables status
  314. Setsebool ftp_home_dir=1
  315. Getsebool -a | grep ftp
  316. Useradd test
  317. Passwd test
  318. Ls -idZ /var/ftp/pub
  319. Chgrp ftp /var/ftp/pub
  320. Chown ftp /vfar/ftp/pub
  321. $Cd /var/ftp/pub
  322. $Touch a1 a2 a3
  323. Cat >> f1
  324. Hello world
  325. Cd /
  326. Ifconfig
  327. ftp 192.168.71.172 (add ip of ur linux sys)
  328. Enter username and password
  329. Login Successful
  330. ----------------------------------------------------------------------------------------------------------------------
  331. APACHE
  332. SU
  333. # rpm -qa | grep httpd
  334. 2. # chkconfig httpd on
  335. 3. # service httpd start
  336. 4. # service httpd restart
  337. 5. # cd /var/www/html
  338. <!DOCTYPE html>
  339. <title>Simple HTML Page</title>
  340. <head>
  341. </head>
  342. <h1> Hello World </h1>
  343. <body>
  344. </body>
  345. </html>
  346. 6. # vim test.html
  347. 7. Esc : wq
  348. 8. Open Firefox browser and enter url
  349. http://localhost/test.html
  350.  
  351. SSI METHOD
  352. r #su -
  353. #ifconfig
  354. 2. #dig (Your_IP_Address)
  355. e,g #dig 192.168.1.3
  356. 3. #vim /etc/httpd/conf/httpd.conf
  357. 1. NameVirtualHost *:80
  358. 2. <VirtualHost *:80>
  359. 3. DocumentRoot
  360. 4. </VirtualHost>
  361. 4. Go to the last (pgDown Button) and uncomment(remove #) the following
  362. 5. Change the path of Document Root to /var/www/html
  363. 6. Now press pg up button and find this line upside line no. 339 and change Directory path to /var/www/html and add Includes after indexes
  364. 7.
  365. 8. Esc :wq
  366. 9. #service httpd restart
  367. 10. To resolve any warning Uncomment servername in line 273
  368. 11. Esc:wq
  369. Practical 8b: Apache SSI (Server Side Includes)
  370. Pracs Page 15
  371. 12. #chkconfig httpd on
  372. 13. #cd /var/www/html
  373. 14. #chmod -R 777 /var/www/html
  374. 15. #vim sitest.shtml (Any Name with extension .shtml)
  375. Enter the code
  376. <!DOCTYPE html>
  377. <html>
  378. <head>
  379. <title>SSI Test Page</title>
  380. </head>
  381. <body>
  382. SSI Test Page Output
  383. <hr>
  384. <p align="center">
  385. This file was last modified on :
  386. <!--#echo var="LAST_MODIFIED" -->
  387. </p>
  388. </body>
  389. </html>
  390. 16. Esc :wq
  391. 17. Now open firefox browser and enter http://localhost/sitest.shtml (Your filename with extension)
  392.  
  393. PDH METHOD
  394.  
  395. In /var/www/html dir
  396. 1. # vim hello.php
  397. <!DOCTYPE html>
  398. <title>PHP Test</title>
  399. <head>
  400. </head>
  401. <?php echo '<p> Welcome to the world of PHP </p>'; ?>
  402. <body>
  403. </body>
  404. </html>
  405. 2. Esc : wq
  406. 3. Open Firefox browser and enter url
  407. http://localhost/hello.php
  408. -------------------------------------------------------------------------------------------------------
  409. GRUB
  410. # vim /boot/grub/grub.conf
  411. Change Timeout to 30 sec
  412. Change Title To NKT Red hat
  413. Esc : wq
  414. Esc :w q !
  415. 5. #init 6 /
Add Comment
Please, Sign In to add comment