Notes from
Fedora Linux Toolbox: 1000+ Commands for Fedora, CentOS, & Red Hat Power Users
Christopher Negus 978-0470082911
last modification: 9/8/15
http://www.amazon.com/Fedora-Linux-Toolbox-Commands-CentOS/dp/0470082917/ref=sr_1_cc_1?ie=UTF8&qid=1283381024&sr=1-1-catcorr
Ch1: Starting with Fedora Linux
About:
Fedora (http://fedoraproject.org)
CentOS (www.centos.org)
Yellow Dog Linux (www.yellowdoglinux.com)
Backtrack http://www.backtrack-linux.org/
DistroWatch (http://distrowatch.com/dwres.php?resource=independence).
Linux Timeline: http://files.cyberciti.biz/uploads/tips/2007/06/44218-linuxdistrotimeline-7.2.png
Comparing
Fedora is the rapid-development, cutting edge Linux system
Novell Suse same basic dual-distribution
Debian a high-quality Linux distribution
Many derivative Linux distributions-- Ubuntu Linux, KNOPPIX live CD based on Debian.
Why command line?
GUIs are meant to be easy & intuitive
Almost any time something goes wrong
Remote systems administration
Features not supported by GUI
GUI is broken or not installed
Finding Commands
bash: anycommand: command not found
why?:
You mistyped the command name.
anycommand is not in your PATH.
Might need to be the root user for the command to be in your PATH.
anycommand not installed on your computer.
Command and Sample Output Description
type mount Show the first mount command in PATH.
whereis mount Show binary, source, and man pages for mount.
locate bash.ps Find bash.ps anywhere in the file system.
which umount Find the umount command anywhere in your PATH or aliases.
rpm -qal |grep umount Find umount in any installed package.
yum whatprovides bzfs find out which package provides some feature or file
yum search somefise find any packages matching in the description, summary & package fields
Command Reference Info
-h or –help
ls --help | less
apropos crontab
whatis cat
man find
info ls
Other Notes
Installing Kali version 1.0.4 (Backtrack 6 ish)
I had display resolution problems after I did all of this, so it is a work in progress
1. Download the correct iso from here: http://www.kali.org/downloads/
2. Open vmware (fusion or workstation)
3. Install kali from iso
I left most stuff at the default install setting except I bumped RAM to 1024
Before you do anything else copy the vmware file to a backup if possible.
4. Log in as root
5. Open terminal
6. apt-get update --fix-missing
7. apt-get install kde-plasma-desktop (from here)
I deviated from the video and set the display manager to kdm
Other instructions can be found here
8. apt-get install yakuake
Up to here it seems to work
9. apt-get install open-vm-tools (from here)
Ended up with 9GB used out of the 20GB I allocated to it
Ch2: Installing and Adding software
USB flash:
Get diskboot.img from one of the online mirrors then execute:
dd if=/media/cdrom/diskboot.img of=/dev/sda
Choosing how install proceeds:
boot: linux text
Other boot options (p17 -- 10%):
Boot Prompt HOWTO (www.tldp.org/HOWTO/BootPrompt-HOWTO.html)
nodmraid
norobe
selinux=0
Installation screens (p18 -- 11%)
Test media, Language, Keyboard, Install or upgrade, Disk partitions, boot loader, network, time zone, root password, software packages, reboot
yum:
repos (p21 -- 12%)
yum list
yum info wordpress
yum search mp3
yum whatprovides ogg123
yum install wordpress
yum groupinstall XFCE
yum update
yum
yum --disablerepo=livna search yum-utils
yum --enablerepo=livna install mplayer
yum –exclude=somepackage update
http://www.xades.com/proj/fedora_repos.html
rpm: (14%)
rpm -ivh some.rpm
rpm -Uvh some.rpm
rpm -e badpackage
rpm -q or -qa or -ql somepackage or rpm -qa | grep ogg
rpm -qi somepackage or -ql somepackage or -qlp some.rpm
Ch 3: Using the shell
Setup:
To get use of the function keys in your virtual machine on a Macbook: in the virtual machine’s settings under keyboard & mouse set Mac Profile
Basic use:
gnome-terminal -x alsamixer Start terminal with alsamixer displayed
xterm
konsole
yakuake
Virtual Terminals
Ctrl-Alt-F1 to F6
ps ps a ps au ps ax ps aw
/etc/inittab & upstart
bash history
history
history 5
!! (rum previous command)
Ctrl-r to search for string in history
Command line completion
tracer Command completion: Completes to traceroute command
cd /home/ch File completion: Completes to /home/chris directory
cd ~jo User homedir completion: Completes to /home/john
echo $PA Env variable completion: Completes to $PATH
Redirecting stdin, stdout, stderr
ls /tmp /tmpp
ls /tmp /tmmp > output.txt
ls /tmp /tmmp 2> errors.txt
ls /tmp /tmmp 2> errors.txt > output.txt
ls /tmp >> output.txt
ls /tmp 2> /dev/null
mail chris < /etc/hosts
ls /tmp | sort
ls /tmp/ /tmmp 2> /dev/null | sort
rpm -qa | grep -i sql | wc -l
Using backticks, you can execute one section of a command line first and feed the output of that
command to the rest of the command line. Here are examples:
rpm -qf `which ps`
ls -l `which traceroute`
Misc
pwd, whoami
Using alias
~/.bashrc or /etc/bashrc
alias ll="ls -lh"
alias la="ls -lah"
alias cl="cd /var/log"
alias ct=”cd /usr/local/tomcat”
Others
.bashrc
watch cat /proc/loadavg
su
su bob
sudo & /etc/sudoers (root ALL=(ALL) ALL)
Environment variables
export PS1='\e[1A\e[s\e[H\e[37;41;1m\e[K \e[1C\u@\h \e[5C \w \e[5C \d \e[5C [\A] \e[0m\e[u\n--> '
PS1, PS2, PS3, PS4
set & env
export ABC=123
export PATH=$PATH:/home/fcaen
NEVER NEVER put . In your path
Simple shell scripts
debugging http://tldp.org/LDP/Bash-Beginners-Guide/html/sect_02_03.html
java scripts
DailyQuote (~/java & ~/Dropbox/Ike/4361/Examples
/etc/crontab
/etc/cron.daily/newquote
myscript.sh
chmod u+x myscript.sh also talk about file permissions (table 4.1 22% loc 830)
#!/bin/bash
MYSTRING=abc
if [ $MYSTRING = abc ] ; then
echo “The variable is abc”
fi
To negate the condition
MYSTRING=abcd
if [ $MYSTRING != abc ] ; then
echo “The variable is not abc”
fi
Examples testing for numbers
MYNUMBER=1
if [ $MYNUMBER -eq 1 ] ; then echo “MYNUMBER equals 1”; fi
if [ $MYNUMBER -lt 2 ] ; then echo “MYNUMBER less than 2”; fi
if [ $MYNUMBER -le 1 ] ; then echo “MYNUMBER less than or equal to 1”; fi
if [ $MYNUMBER -gt 0 ] ; then echo “MYNUMBER greater than 0”; fi
if [ $MYNUMBER -ge 1 ] ; then echo “MYNUMBER greater than or equal 1”; fi
Testing File names
filename=$HOME
if [ -e $filename ] ; then echo “$filename exists”; fi
if [ -f “$filename” ] ; then
echo “$filename is a regular file”
elif [ -d “$filename” ] ; then
echo “$filename is a directory”
else
echo “I have no idea what $filename is”
fi
Other file test operators (table 3.1 p46 20% loc 728)
case “$VAR” in
string1)
{ action1 };;
string2)
{ action2 };;
*)
{ default action } ;;
esac
for NUMBER in 0 1 2 3 4 5 6 7 8 9
do
echo The number is $NUMBER
done
for FILE in `/bin/ls`; do echo $FILE; done
x=1
while [ $x -le 5 ] do echo "Welcome $x times" x=$(( $x + 1 )) done
VAR=0
until [ $VAR -eq 3 ]; do echo $VAR; VAR=$[$VAR+1]; done
---------------
#!/bin/bash #simple script to show command line args and if test echo $0 echo $1 echo $2 if [ "$1" ]; then echo string not empty else echo string empty fi
Debugging
bash -x myscript.sh
Share with your friends: |