Uly.me

cloud engineer

  • Home
  • About
  • Archives
Home/2019/Archives for November 2019

Archives for November 2019

November 27, 2019

Set Immutable Attribute

If you don’t want a file edited or deleted, you can set the immutable attribute to ON. If activated, not even root or the owner of the file can delete it. Users with write access can still read it, but they obviously will not be able to modify it. To unset it, just use the -i option.

# Set immutable attribute
sudo chattr +i text.txt
 
# Unset immutable attribute
sudo chattr -i text.txt

# Set immutable attribute sudo chattr +i text.txt # Unset immutable attribute sudo chattr -i text.txt

Filed Under: Linux Tagged With: attribute, delete, immutable, read, root, write

November 27, 2019

AWS CLI Add Network Interface

Create a new interface via AWS CLI with static IP.

$ aws ec2 create-network-interface \
--subnet-id subnet-xxxxxxx \
--description "second ip" \
--groups sg-xxxxxxx \
--private-ip-address 10.0.0.16

$ aws ec2 create-network-interface \ --subnet-id subnet-xxxxxxx \ --description "second ip" \ --groups sg-xxxxxxx \ --private-ip-address 10.0.0.16

Filed Under: Cloud Tagged With: aws, cli, network-interface, subnet

November 27, 2019

Tcpdump

Tcpdump is a command line utility that allows you to capture and analyze network traffic going through your system. It is often used to help troubleshoot network issues.

# Find out if tcpdump is installed
$ which tcpdump
/usr/sbin/tcpdump
 
# Install tcpdump
sudo yum install -y tcpdump
 
# Find which interface is available to you
tcpdump -D
 
# Capture on eth0. Use Ctrl-C to end capture.
tcpdump -i eth0
 
# Capture after 10 packets
tcpdump -i eth0 -c10
 
# Filter by port
tcpdump -i any -c10 -nn port 80
 
# Filter by ip address
tcpdump -i any -c10 -nn host 192.168.1.23
 
# Filter by source or destination ip
tcpdump -i any -c10 -nn src 192.168.1.23
tcpdump -i any -c10 -nn dst 192.168.1.23
 
# Filter by destination ip and port
tcpdump -i any -c5 -nn src 192.168.1.23 and port 80
 
# Save output to a file (binary format)
tcpdump -i any -c10 -nn -w http.pcap port 80
 
# Save output to a file (text format)
tcpdump -nn -r http.pcap

# Find out if tcpdump is installed $ which tcpdump /usr/sbin/tcpdump # Install tcpdump sudo yum install -y tcpdump # Find which interface is available to you tcpdump -D # Capture on eth0. Use Ctrl-C to end capture. tcpdump -i eth0 # Capture after 10 packets tcpdump -i eth0 -c10 # Filter by port tcpdump -i any -c10 -nn port 80 # Filter by ip address tcpdump -i any -c10 -nn host 192.168.1.23 # Filter by source or destination ip tcpdump -i any -c10 -nn src 192.168.1.23 tcpdump -i any -c10 -nn dst 192.168.1.23 # Filter by destination ip and port tcpdump -i any -c5 -nn src 192.168.1.23 and port 80 # Save output to a file (binary format) tcpdump -i any -c10 -nn -w http.pcap port 80 # Save output to a file (text format) tcpdump -nn -r http.pcap

Here’s a good intro article about tcpdump.

Filed Under: Linux Tagged With: analysis, firewall, network, tcpdump

November 26, 2019

Change MTU Size

MTU means maximum transmission unit. The default value is 1500 for Ethernet, which is also the standard for the Internet. If your application or network requires a different MTU size, you can set the MTU size by running the following commands.

# Edit ifcfg-eth0
vi /etc/sysconfig/network-scripts/ifcfg-eth0
 
#Add MTU, settings:
MTU="1460"
 
# Save and close the file. Restart networking:
service network restart

# Edit ifcfg-eth0 vi /etc/sysconfig/network-scripts/ifcfg-eth0 #Add MTU, settings: MTU="1460" # Save and close the file. Restart networking: service network restart

Filed Under: Cloud, Linux Tagged With: mtu, network, size

November 19, 2019

Tail A File in Windows Server

Linux has tail command. What about Windows? You can use Powershell to tail a file.

Get-Content myLog.log –Wait

Get-Content myLog.log –Wait

Filed Under: Windows Tagged With: file, log, powershell, tail, windows

  • 1
  • 2
  • Next Page »
  • Cloud
  • Linux
  • Git

Copyright © 2012–2021