Showing posts with label linux. Show all posts
Showing posts with label linux. Show all posts

30 September 2022

Sejarah ip yg pernah pc ubuntu anda pegang

 history of ip has been assign to your pc


Ada 2 command yg boleh senaraikan IP yg pc anda dapat dari DHCP.


1) sudo cat /var/log/syslog | grep -Ei 'dhcp' | grep ip_address

2) sudo journalctl | grep -Ei 'dhcp' | grep ip_address

28 July 2020

LVM, add new partition to extend lv(logical volume)

Concept:

- has 3 logical layer
-- pv(physical volume)
       partition to be use for LVM
-- gv(group volume)
       group of partition(pv) seen as 1 big harddisk. One system/OS could have multiple gv
-- lv(logical volume)
       lv to gv, is as partition to harddisk




To extend partition(lvm), by adding new partition to be part of the lvm

1- create partition on new drive
     

2- register the partition as pv
      pvcreate /dev/sdb1
      pvdisplay



3- add the pv  to be a member of on of the gv
       use vgdisplay to check name existing volume group(vg)

       vgextend _name_of_volume_group_ /dev/sdb1



4-  extend the current lvm to utilize the free space in gv
       lvm to gv is as a partition to harddisk. At this stage, our gv size has increase. So we have oppurtunity to increase size of the lvm base on free size on the gv.

       use lvdisplay to check LV_path

      lvextend -l +100%FREE __LV_path__
        or
       lvextend -L +100G __LV_path__



5- extend filesystem
       resize2fs /dev/mapper/__LV_Name__





ref:
1- https://www.krenger.ch/blog/linux-lvm-how-to-adding-a-new-partition/

04 September 2019

Masalah mount windows share folder

semak senarai share folder windows dari linux

smbclient -L  -U  -d 256


ubuntu 16 default guna protokol smb 1

Manakala window tak support smb1, sebaliknya smb2.1 dan 3.

Maka tambah -m utk specify protokol

smbclient -L  -U  -d 256 -m smb2

Utk mount tambah vers=3 pada parameter -o

sudo mount -o vers=3.0,username=,uid=,gid=,forceuid,forcegid, //IP_Address/share_name /mnt/path/




Domain(Active Directory) user:
smbclient -L  -U _user_  -W _domain_name_ -d 256 -m smb2
sudo mount -o vers=3.0,username=_user_,domain=_domain_ //IP_Address/share_name /mnt/path/


Interactively:
smbclient //10.108.242.242/FSC -U _user_ -W _domain_



06 November 2018

systemctl

Kek mano systemctl baco konpig pail?

list all service

$ systemctl -a | grep "myservice"



$ systemctl show "mycervice"  | grep -i path

27 March 2018

bunuh yg kebal

Not able to kill a task using kill -9




# ps aux|grep subl 

 root      3018  2.2  1.0 289008

 61872 ?        Ds   12:30   5:27 /opt/sublime_text/sublime_text 


The D in the STAT column means it's in an in "Uninterruptible sleep". That usually translates to something waiting for an IO command. These cannot be interrupted by kill.
You might be able to jimmy it back to life by unmounting your SSHFS mount.

26 January 2018

gnome3 alt+tab cuurent workspace only

ciri asal gnome3 utk ALT+TAB, akan papar windows dari semua workspace.
Utk papar windows dlm workspace semasa sahaja:

gsettings set org.gnome.shell.app-switcher current-workspace-only true

16 December 2017

hidup kekal

supervisord dan daemontools expect to be a parent of the 'process' that run foreground.
monit expect process run in background and has pid file.

saya pilih supervisord

https://news.ycombinator.com/item?id=1368855

11 February 2016

SELinux


How SELinux Works

Consider these pieces of the SELinux puzzle:
  • Subjects
  • Objects
  • Policy
  • Mode
When a subject (such as an application) attempts to access an object (such as a file), the SELinux Security Server (inside the kernel) runs a check against the Policy Database. Depending on the current mode, if the SELinux Security Server grants permission, the subject is given access to the object. If the SELinux Security Server denies permission, a denied message is logged in /var/log/messages.

The Modes

SELinux has three modes (which can be set by the user). These modes will dictate how SELinux acts uponsubject request. The modes are: 
  • Enforcing — SELinux policy is enforced and subjects will be denied or granted access to objects based on the SELinux policy rules
  • Permissive — SELinux policy is not enforced and does not deny access, although denials are logged
  • Disabled — SELinux is completely disabled





ref:
http://www.linux.com/learn/docs/ldp/883671-an-introduction-to-selinux

21 November 2014

tambah syscall sendiri

Cara nak tambah syscall sendiri ke dalam linux kernel. Melibatkan recompile kernel

////////////////////////////////////////////////////////////////////////////////////
// 1)  source_path/arch/x86/syscalls/syscall_32.tbl
# The format is:
#
356     i386    memfd_create            sys_memfd_create
357     i386     mhsyscall            sys_mhsyscall  ( new line)


////////////////////////////////////////////////////////////////////////////////////
// 2)  source_path/include/linux/syscalls.h

// last line
asmlinkage long sys_opsyscall(const char *test);
#endif

////////////////////////////////////////////////////////////////////////////////////
// 3)   source_path/mhsyscall/mhfzsyscall.c   ( nama c file suka hati)

#include
#include

//The system call
asmlinkage long sys_mhsyscall(const char *test)
{
   printk(KERN_ALERT "Called with string: %s\n", test);
   // 0 for success
   return 0;
}





////////////////////////////////////////////////////////////////////
// 4)   source_path/mhsyscall/Makefile

// Include the object in the kernel core
obj-y := mhfzsyscall.o


/////////////////////////////////////////////////////////////////////////
// 5)    source_path/Makefile

# Objects we will link into vmlinux / subdirs we need to visit
init-y          := init/
drivers-y       := drivers/ sound/ firmware/
net-y           := net/
libs-y          := lib/
core-y          := usr/ mhsyscall/   ( edit line )




//////////////////////////////////////////////////////////////
// 6)  compile
# make


///////////////////////////////////////////////////////
//  7) userspace binary to call mhsyscall (pemanggil.c)

#include

int main(){
   syscall(357, "Mesage from user space program");
   return 0;
}
//  gcc -o pemanggil pemanggil.c



ref https://www.youtube.com/watch?v=5rr_VoQCOgE&feature=youtu.be

23 January 2014

Logical Volume

usefull command:
  • lvs
  • fdisk
    • create partition with Label ID: 8e
  • pvcreate
  • vgcreate    (utk tambah saiz, tak perlu yg ini)
  • lvcreate
  • vgextend 
    • vgextend vg_data /dev/sda6
  • lvextend
    • lvextend -L +100G /dev/mapper/vg_data /dev/sda6
  • resize2fs
    • resize2fs /dev/mapper/vg_data-lvdata
  • other
    • vgdisplay
    • lvdisplay
    • pvdisplay

Ringkasan:
1) create partition baru, type 8e
2) create volume group guna partition itu
3) create logical volume(guna semua saiz partition atau sebahagian)
4) jika hanya guna sebahagian, nanti bila dah penuh boleh extend(dengan lvextend)

Besarkan saiz guna partition baru(berlainan):
1) add partition baru ke volume group sedia ada (vgextend)
2) besarkan logical volume, guna ruang dari partition baru
        lvextend -L +G /dev/mapper/vg_data /dev/sda6
3) resize file system (resize2fs)

ref>>  http://www.linuxuser.co.uk/features/resize-your-disks-on-the-fly-with-lvm
ref>> http://stackoverflow.com/questions/16515739/extending-logical-volume-in-ubuntu


09 January 2014

masalah ps | grep dalam crontab

guna ps -auxww | grep cari

bila run dalam cron, job tak attach pada tty/pty, maka tak tahu berapa saiz lebar screen. Jadi tambah parameter 'ww' pada ps:    ps -auxww | grep cari.


ref: http://unix.derkeiler.com/Newsgroups/comp.unix.bsd.freebsd.misc/2006-09/msg00102.html

18 December 2013

bash skrip: beri input pada program

#!/usr/bin/expect -f
spawn openvpn client.warriors.conf.open
match_max 100000
expect "*?assword:*"
send -- "mypassword"
send -- "\r"
expect eof

ref: http://stackoverflow.com/questions/11240184/pass-private-key-password-to-openvpn-command-directly-in-ubuntu-10-10

16 November 2012

optimus on linux

https://wiki.ubuntu.com/Bumblebee


Bumblebee aims to provide support for NVIDIA Optimus laptops for GNU/Linux distributions. Using Bumblebee, you can use your NVIDIA card for renderinggraphics which will be displayed using the Intel card.

01 November 2012

encrypt: loop file


LOOP TUTORIAL
loop tutorial at http://www.saout.de/tikiwiki/tiki-index.php?page=looptutorial

Setting the Loop File
        1>      dd if=/dev/urandom of=/home/secret bs=1M count=100
        2>      losetup /dev/loop0 /home/secret
        3>      modprobe dm_crypt
        4>      cryptsetup -c aes -y create secret /dev/loop0
        5>      mke2fs -j /dev/mapper/secret     (ext3)
        5>      mke2fs -t ext4 -j /dev/mapper/secret     (ext3)
        6>      mount /dev/mapper/secret /mnt/secret

24 May 2011

crossover: takleh restore window word


[Manage Bottle]->[ControlPanel]->[WineConfiguration]->[LaunchedSelectedItems]->[Graphics]
Uncheck Below options:
  • Allow the window manager to decorate the windows
  • Allow the window manager to control the windows