How to divert connection or packet before routing decision entering the default

Posted on

before the packets ports (443) entering the firewall i would like to divert incoming packet of server (443) to input chain goes to FORWARD chain<br> so thats the incoming packets 100.43.xx.xx –sport 443 are send it to FORWARD instead of input chain<br> how to configure this in OUTPUT,FORWARD,POST AND PREROUTING CHAIN and this is my
Read more

How to get the full path and directory of a Python script itself?

Posted on

In a Python script, how to get the full path and directory of the Python script itself? To get the path of the current file (the script itself), you can use __file__. To resolve any symbolic links in the path, you can use os.path.realpath(). Putting them together, you can do os.path.realpath(__file__) to get the full
Read more

How to improve video rendering quality in MPlayer

Posted on

MPlayer has lots options for video rendering and filtering. Any suggestions on good MPlayer options that improve video rendering quality nicely? My ~/.mplayer/config is as follows with 2 profiles: [fast] vf=eq2 [default] vf=hqdn3d vo=gl:yuv=3:lscale=5:cscale=5 ao=pulse The default one gives good video quality by using the hqdn3d video filter while the CPU usage is high. If
Read more

How to configure /dev/shm size of Linux?

Posted on

/dev/shm is a nice in memory disk on Linux. The default size seems half of the physical memory’s size. How to configure shm size of Linux? And what’s the consequence? To change the configuration for /dev/shm, add one line to /etc/fstab as follows. tmpfs /dev/shm tmpfs defaults,size=8g 0 0 Here, the /dev/shm size is configured
Read more

How to exclude a package from a specific repository only in yum?

Posted on

This post https://www.systutorials.com/1661/making-dnf-yum-not-update-certain-packages/ introduces how to exclude a package from yum. But is it possible to exclude a package from a specific repository only? For example, a repository R1 I am using contains an updated version of gdb while I don’t want to use the gdb from it as I trust the version (although older)
Read more

How to create a file if not exist and open it in read and write modes in C++?

Posted on

How to create a file if not exist and open it in read and write modes in C++? For example, I would like open a fstream on /tmp/cache to be able to read it and append to it. If the file does not exist yet, create one. A simple code like std::fstream fs(“/tmp/cache”, std::ios::in |
Read more

`readlink -m` equivalent function in Python to get canonical file name

Posted on

readlink -m can get canonical file name by resolving every symlinks in every component of the given path recursively. In Python, the os.readlink() function does not do so. Any equivalent function in Python to the readlink -m command line? Specifically, it does: canonicalize by following every symlink in every component of the given name recursively,
Read more

How to generate a password in Shell on Linux?

Posted on

Admins usually need to generate some passwords for others, such as when creating a new user in a Linux system. How to generate a password in Shell on Linux? Several possible and short methods. Here, we generate a password of length 8. Using pwgen: $ pwgen 8 1 dao3PaW9 Password based on base64 (note that
Read more

How to split a string by string in Python?

Posted on

How to split a string by string in Python? For example, “a string separated by space” => [“a”, “string”, “separated”, “by”, “space”] and “a,string,separated,by,comma” => [“a”, “string”, “separated”, “by”, “comma”] Python’s string.split() standard library function, if provided a separator, will split the string by the separator, for example >>> str2 = “a,string,separated,by,,,comma” >>> str2.split(“,”) [‘a’,
Read more

How to make iptables/ip6tables configurations permanent across reboot on CentOS 7 Linux?

Posted on

How to make iptables/ip6tables configurations permanent across reboot on CentOS 7 Linux? CentOS 7 uses FirewallD by default. If you would like to manage iptables/ip6tables rules directly without using FirewallD, you may use the old good iptables-services service which will load the iptables/ip6tables rules saved in /etc/sysconfig/iptables and /etc/sysconfig/ip6tables when it is started during boot
Read more