Linux_without_a_kleenex

Linux notes

get file names sorted by date


the below is similar to 
ls -ltr








This will print the file names in a directory called "old" in date order

find ./old -printf "%T+\t%f\n" | sort | awk '{ print $2 } '  > myoutfile.txt

to explain it:
find is the command to find the file names
./old is the path name I selected
-printf is the option to output the file %T timestamp followed by a \t tab followed by the %f filename
sort will sort by timestamp (the first column above)
awk print $2 will show ONLY the 2nd column (which is filename), and will NOT show the 1st column (which is timestamp)
myoutfile.txt is the file you wish to put the results into

sudo usermod -l newUsername oldUsername
change home-folder
sudo usermod -d /home/newHomeDir -m newUsername

install chrome web browser on ubuntu

sudo apt-get install chromium-browser

unbuntu mate (pronounce MATAY)
goodness in a distro v15.04
https://ubuntu-mate.org/
Eeeeeeeeeaaaasy on CPU
The MATE Desktop Environment is the continuation of GNOME 2. 2

Cool Chrome OS looking iso desktop

http://chromixium.org/

Printers

open the add printer dialog
system-config-printer

Upgrade/Update (also dos apps like firefox)

sudo apt-get update
sudo apt-get upgrade

unbuntu Launcher shortcut bar

Resort/order launcher icons

 just click and hold, then you can drag-n-drop them

Lock to Launcher (Ubuntu)

 open an app
   then u can right click its launcher icon, and menu select "Lock to Launcher"

Enable soundport/jack/Headphones
cd
/usr/share/pulseaudio/alsa-mixer/paths/
sudo
cp analog-output-headphones.conf analog-output-headphones.bak
sudo
nano analog-output-headphones.conf

Edit
[Element
Speaker]
switch
= on
volume
= ignore

Save/exit nano.

backup corrected version (incase updates/fixes unfix this):
sudo
cp analog-output-headphones.conf analog-output-headphones.fixed

iptables firewall

list current iptables firewall rules:
sudo iptables -L
Output:
Chain INPUT (policy ACCEPT)
target     prot opt source               destination      
Chain FORWARD (policy ACCEPT)
target     prot opt source               destination      
Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination

we have our three default chains (INPUT,OUTPUT, and FORWARD).
 We also can see each chain's default policy (each chain has ACCEPT as its default policy).
  We also see some column headers, but we don't see any actual rules.

This is because Ubuntu doesn't ship with a default rule set.

see commands necessary to enable each rule:
sudo iptables -S
Output:
-P INPUT ACCEPT
-P FORWARD ACCEPT
-P OUTPUT ACCEPT



to flush/scrap current rules and start over:
sudo iptables -F


accept ssh (assuming you are currrently using an ESTABLISHED ssh connectionn)
sudo iptables -A INPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT


sudo iptables -A INPUT -p tcp --dport 22 -j ACCEPT
sudo iptables -A INPUT -p tcp --dport 80 -j ACCEPT

allow svr to connect to its own loopback
sudo iptables -I INPUT 1 -i lo -j ACCEPT



save rules
sudo invoke-rc.d iptables-persistent save

Chronological Job scheduler “Crontab “

Edit
  Crontab –e
List
 Crontab –l

# this is a comment
# min hr   dayOfMon   Month  dayOfWeek    myCommand
# * means all /wildcard  …so 
$ 59 12 * * * bla     …means bla will run at 12:59 each day of week/mon

Scripts

Tbl06-01
Awk is used to gen reports
*      Programmers and system administrators often customize the .bashrc file to suit their needs


59 23  * * *  echo “Hello World”  >> /tmp/hello.txt

Loops

While [ condition ]
 Do
   Cmd
Done
Vim myscript.sh
Let x=1
While [ $x –lt 10 ]
Do
   Sleep .2
   Echo “test”
  Let x+=1
Do
Chmod +x myscript.sh

Common Commands:

Find/search for files (case Insensitive):
    Sudo find –iname
    Sudo find php*
    Sudo find *.conf

Networking:

Sudo ifconfig
 Sudo /etc/init.d/networking start/ stop/restart
Sudo dhcpclient …to renew your ip lease
Sudo ufw status/enable/disable …turn on or off your firewall
Sudo ufw default allow/deny
Sudo ufw allow  from x.x.x.x

Security

Sudo adduser myDude
Sudo vim /etc/passwd    …View users
Sudo passwd testuser …to reset the password
Sudo userdel myDude
Sudo groupdel
Sudo Deluser  eli testGroup …del user from group






Comments

Popular Posts