GithubHelp home page GithubHelp logo

linux-and-mac-command-line-cheat-sheet's Introduction

linux-command-line-cheat-sheet

Change password on root user and user account

To change the root password: sudo passwd

To change your user password: passwd

To change other users password: sudo passwd USERNAME

ref: change-password-on-root-user-and-user-account

HOST name change:

sudo nano /etc/hosts - then rename

and

hostnamectl set-hostname new-hostname

ref : how-do-i-change-the-hostname

ipv4 forward related permanent

cat /proc/sys/net/ipv4/ip_forward
sudo nano /etc/sysctl.conf
sudo /etc/init.d/procps restart
cat /proc/sys/net/ipv4/ip_forward
IPv4 forward for a temp on any session:
cat /proc/sys/net/ipv4/ip_forward
echo 1 > /proc/sys/net/ipv4/ip_forward

ref: how-to-make-ip-forwarding-permanent

SSH:

sudo apt-get update
sudo apt-get install openssh-server

ref : why-am-i-getting-a-port-22-connection-refused-error

How to install a deb file, by dpkg -i or by apt?

Install your foo.deb file with sudo dpkg -i foo.deb.

If there are some errors with unresolved dependencies, run sudo apt-get install -f or sudo apt-get install -f --fix-missing afterwards.

ref: how-to-install-a-deb-file-by-dpkg

Installing a root/CA Certificate in ubuntu

Given a CA certificate file alamin.crt, follow these steps to install it on Ubuntu:

  1. [ Optional ] Create a directory for extra CA certificates in /usr/share/ca-certificates:

sudo mkdir /usr/share/ca-certificates/extra

  1. Copy the CA .crt file to this directory:

sudo cp alamin.crt /usr/share/ca-certificates/extra/alamin.crt

  1. Let Ubuntu add the .crt file's path relative to /usr/share/ca-certificates to /etc/ca-certificates.conf:

sudo dpkg-reconfigure ca-certificates

  • In case of a .pem file on Ubuntu, it must first be converted to a .crt file:

    openssl x509 -in foo.pem -inform PEM -out foo.crt

To do this non-interactively, run:
sudo update-ca-certificates

ref: Installing a root/CA Certificate in ubuntu

Configure a network interface into promiscuous mode

Your interface is not in promiscous mode. Use: ip link set eth1 promisc on netstat -i The flag will be updated to BMPRU. Flag details are as follows:

  • B flag is for broadcast
  • M flag is for multicast
  • P flag is for promisc mode
  • R is for running
  • U is for up

ref: configure-a-network-interface-into-promiscuous-mode

Cheat Sheet

cat command

cat filename - to see the content of a file

head command

head filename - to see first 10 lines of the content of a file
head -20 filename - to see first 20 lines of the content of a file

tail command

tail filename - to see last 10 lines of the content of a file
tail -20 filename - to see last 20 lines of the content of a file

Numbering the Lines

nl filename - to see the content of a file with number

Filtering Text with grep

cat filename | grep some_text - to see the content of a file with filtered text only

more command

more filename - to see the content of a file with scrolling option

less command

less filename - to see the content of a file with scrolling option /keyword - you can search a keyword inside the file, n press n to search next occurance

sed command

sed s/mysql/MYSQL/2 /etc/snort/snort.conf > snort2.conf - to find and replace, The s command performs the substitution: you first give the term you are searching for (mysql) and then the term you want to replace it with (MySQL), separated by a slash (/). The g flag tells Linux that you want the replacement performed globally. Then the result is saved to a new file named snort2.conf.

==================================================================================================================================================

Mac-command-line-cheat-sheet

How to Allow Apps from Anywhere in macOS Gatekeeper (Mojave, Sierra, High Sierra)

To do disable, run:
sudo spctl --master-disable
To do enable, run:
sudo spctl --master-enable
Checking for existing SSH keys

Before you generate an SSH key, you can check to see if you have any existing SSH keys.

  1. Open Terminal. Enter ls -al ~/.ssh to see if existing SSH keys are present: $ ls -al ~/.ssh Lists the files in your .ssh directory, if they exist Check the directory listing to see if you already have a public SSH key.

What is the correct way to alias applications in OS X through bash?

TEMP

alias tmc='/Users/alamin/work/gitLab/machine-learning/MOOC_Data_Analysis_with_Python_Summer_2019/./tmc'

NOTICE the /./ at the end,

For PERMANENT ln -s /Users/alamin/work/gitLab/machine-learning/MOOC_Data_Analysis_with_Python_Summer_2019/./tmc /usr/local/bin/tmc

reference: configure-a-network-interface-into-promiscuous-mode

linux-and-mac-command-line-cheat-sheet's People

Contributors

al-amin avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.