Wednesday, October 21, 2015

UNIX

--BEGIN--
UNIX
----
df: Display free disk space
du: Estimate file space usage
vmstat: Report virtual memory statistics
uname: Print system information
----
EDIT
bzip2:Compress or decompress named file(s)
gzip: Compress or decompress named file(s)
 zip: Package and compress (archive) files.
rev: Reverse lines of a file
awk: Find and Replace text, database sort/validate/index

  expand: Convert tabs to spaces
unexpand: Convert spaces to tabs

  rar: Archive files with compression
unrar: Extract files from a rar archive

head: Output the first part of file(s)
tail: Output the last part of file
----
ftp: File Transfer Protocol
sftp: Secure File Transfer Program
----
COMMANDS
if: Conditionally perform a command
continue: Resume the next iteration of a loop •
break: Exit from a loop •
case: Conditionally perform a command
while: Execute commands
until: Execute commands (until error)
command: Run a command - ignoring shell functions •
cron: Daemon to execute scheduled commands
crontab: Schedule a command to run at a later time
eval: Evaluate several commands/arguments
exec: Execute a command

read: Read a line from standard input •
readarray: Read from stdin into an array variable •
local: Create variables •
declare: Declare variables and give them attributes •
let: Perform arithmetic on shell variables •
readonly: Mark variables/functions as readonly

  set: Manipulate shell variables and functions
unset: Remove variable or function names
type: Describe a command •
true: Do nothing, successfully
----
USER
whoami: Print the current user id and name (`id -un')
users: List users currently logged in
who: Print all usernames currently logged in
passwd: Modify a user password
su: Substitute user identity
sudo: Execute a command as another user
useradd: Create new user account
userdel: Delete a user account
usermod: Modify user account
write: Send a message to another user
----
GROUP
groupdel: Delete a group
groupmod: Modify a group
chgrp: Change group ownership
chown: Change file owner and group
groupadd: Add a user security group
groups: Print group names a user is in
id: Print user and group id's
----
more: Display output one screen at a time
less: Display output one screen at a time
clear: Clear terminal screen
echo: Display message on screen •
----
NETWORK
ping: Test a network connection
netstat: Networking information
mtr: Network diagnostics (traceroute/ping)
ifconfig: Configure a network interface
ifup: Start a network interface up
ifdown: Stop a network interface
----
PRINTER
lpc: Line printer control program
lpr: Off line print
lprint: Print a file
lprintq: List the print queue
printcap: Printer capability database
pr: Prepare files for printing
----
PROCESS
top: List processes running on the system
ps: Process status
kill: Kill a process by specifying its PID
killall: Kill processes by name
fuser: Identify/kill the process that is accessing a file
htop: Interactive process viewer
pkill: Kill processes by a full or partial name.
wait: Wait for a process to complete •
----
mount: Mount a file system
umount: Unmount a device
----
FILES
stat: Display file or file system status
file: Determine file type
ls: List information about file(s)
lsof: List open files
cat: Concatenate and print (display) the content of files

cp: Copy one or more files to another location
rename: Rename files
rm: Remove files

sort: Sort text files
sum: Print a checksum for a file

cmp:  Compare two files
comm: Compare two sorted files line by line

chmod: Change access permissions
dd: Convert and copy a file, write disk headers, boot records

locate:  Find files
slocate: Find files
find: Search for files that meet a desired criteria
grep:  Search file(s) for lines that match a given pattern
fgrep: Search file(s) for lines that match a fixed string
egrep: Search file(s) for lines that match an extended expression
----
basename: Strip directory and suffix from filenames

split:  Split a file into fixed-size pieces
csplit: Split a file into context-determined pieces
cut: Divide a file into several parts

diff: Display the differences between two files
diff3: Show differences among three files
----
JOB
fg: Send job to foreground
bg: Send to background
jobs: List active jobs •
lprintd: Abort a print job
lprm: Remove jobs from the print queue
nice: Set the priority of a command or job
renice: Alter priority of running processes
----
ENVIRONMENT
printenv: Print environment variables
export: Set an environment variable
env: Environment variables
----
DIRECTORY
pwd: Print Working Directory
cd: Change Directory
mkdir: Create new directory
rmdir: Remove directory
mv: Move or rename files or directories
dir: Briefly list directory contents
vdir: Verbosely list directory contents (`ls -l -b')
v:    Verbosely list directory contents (`ls -l -b')
----
exit: Exit the shell
logout: Exit a login shell •
return: Exit a shell function
suspend: Suspend execution of this shell •
shutdown: Shutdown or restart linux
reboot: Reboot the system
----
hostname: Print or set system name
logname: Print current login name
---
history: Command History
man: Help manual
help: Display help for a built-in command •
apropos: Search Help manual pages (man -k)
----
TOOLS
cal: Display a calendar
date: Display or change the date & time
dc: Desk Calculator
aspell: Spell Checker
bc: Arbitrary precision calculator language
ddrescue: Data recovery tool
vi: Text Editor
----
alias:   Create an alias •
unalias: Remove an alias •
----
apt-get:  Search for and install software packages (Debian/Ubuntu)
aptitude: Search for and install software packages (Debian/Ubuntu)

bash: GNU Bourne-Again SHell
builtin: Run a shell builtin

cfdisk: Partition table manipulator for Linux

chroot: Run a command with a different root directory
chkconfig: System services (runlevel)
cksum: Print CRC checksum and byte counts
----
dig: DNS lookup
dircolors: Colour setup for `ls'
dirname: Convert a full pathname to just a path
dirs: Display list of remembered directories
dmesg: Print kernel & driver messages
eject: Eject removable media
enable: Enable and disable builtin shell commands •

ethtool: Ethernet card settings

expect: Automate arbitrary applications accessed over a terminal

expr: Evaluate expressions
false: Do nothing, unsuccessfully
fdformat: Low-level format a floppy disk
fdisk: Partition table manipulator for Linux
fmt: Reformat paragraph text
fold: Wrap text to fit a specified width.
for: Expand words, and execute commands
format: Format disks or tapes
free: Display memory usage
fsck: File system consistency check and repair

function: Define Function Macros

gawk: Find and Replace text within file(s)
getopts: Parse positional parameters
hash: Remember the full pathname of a name argument

iconv: Convert the character set of a file
----
import: Capture an X server screen and save the image to file
install: Copy files and set attributes
ip: Routing, devices and tunnels

join: Join lines on a common field

link: Create a link to a file
ln: Create a symbolic link to a file
look: Display lines beginning with a given string

make: Recompile a group of programs
mkfifo: Make FIFOs (named pipes)
mkisofs: Create an hybrid ISO9660/JOLIET/HFS filesystem
mknod: Make block or character special files
most: Browse or page through a text file

mtools: Manipulate MS-DOS files
mmv: Mass Move and rename (files)

nl: Number lines and write files
nohup: Run a command immune to hangups
notify-send: Send desktop notifications
nslookup: Query Internet name servers interactively
open: Open a file in its default application
op: Operator access
paste: Merge lines of files
pathchk: Check file name portability
----
popd: Restore the previous value of the current directory
pushd: Save and then change the current directory
----
printf: Format and print data •

pv: Monitor the progress of data through a pipe
----
quota: Display disk usage and limits
quotacheck: Scan a file system for disk usage
quotactl: Set disk quotas
----
ram: ram disk device
rcp: Copy files between two machines

remsync: Synchronize remote files via email
rsync: Remote file copy (Synchronize file trees)
screen: Multiplex terminal, run remote shells via ssh
scp: Secure copy (remote file copy)
sdiff: Merge two files interactively
sed: Stream Editor
select: Accept keyboard input
seq: Print numeric sequences
shift: Shift positional parameters
shopt: Shell Options
sleep: Delay for a specified time
source: Run commands from a file '.'
ssh: Secure Shell client (remote login program)
strace: Trace system calls and signals

sync: Synchronize data on disk with memory
tar: Store, list or extract files in an archive
tee: Redirect output to multiple files
test: Evaluate a conditional expression
time: Measure Program running time
timeout: Run a command with a time limit
times: User and system times
touch: Change file timestamps

tput: Set terminal-dependent capabilities, color, position
traceroute: Trace Route to Host
trap: Run a command when a signal is set(bourne)
tr: Translate, squeeze, and/or delete characters
tsort: Topological sort
tty: Print filename of terminal on stdin
ulimit: Limit user resources •
umask: Users file creation mask

uniq: Uniquify files
units: Convert units from one scale to another

unshar: Unpack shell archive scripts
uptime: Show uptime
----
uuencode: Encode a binary file
uudecode: Decode a file created by uuencode
----
watch: Execute/display a program periodically
wc: Print byte, word, and line counts
whereis: Search the user's $path, man pages and source files for a

program
which: Search the user's $path for a program file

wget: Retrieve web pages or files via HTTP, HTTPS or FTP

xargs: Execute utility, passing constructed argument list(s)
xdg-open: Open a file or URL in the user's preferred application.
yes: Print a string until interrupted
.: Run a command script in the current shell
!!: Run the last command again
###: Comment / Remark

Commands marked • are bash built-ins
----
CLI: command line interfaces.
bash:Bourne Again SHell
----
superuser:the last character of your shell prompt is #
superuser has administrative privileges.
----
To copy and paste with the mouse:
1. select text
2. press the middle mouse button
---
pwd (print working directory)
cd (change directory)
ls (list files and directories)
----
On most systems, your home directory is:/home/your_user_name
----
The "." notation refers to the working directory itself
The ".." notation refers to the working directory's parent

directory.
----
Change to the parent directory:
cd ..
----
Change to the a directory called "bin" under the current

directory:
cd bin
----
change to your home directory:
cd
----
change to the home directory of the specified user:
cd ~user_name
----
changes to the previous directory:
cd -
----
File names that begin with a period character are hidden.
ls will not list them unless you say ls -a.
----
File names are case sensitive.
----
Though Linux supports long file names which may contain embedded

spaces and punctuation characters, limit the punctuation

characters to period, dash, and underscore. Most importantly, do

not embed spaces in file names. If you want to represent spaces

between words in a file name, use underscore characters.
----
ls (list files and directories)
less (view text files)
file (classify a file's contents)
----
List the files in the /bin directory:
ls /bin
---
List the files in the working directory in long format
ls -l
----
List the files in the /bin and /etc directory in long format:
ls -l /etc /bin   
----
List all files (even hidden) in the parent directory in long

format:

ls -la ..   
----
Group:The name of the group that has file permissions in addition

to the file's owner.
Owner:The name of the user who owns the file.
File Permissions: A representation of the file's access

permissions.
"-" :regular file
"d" :directory
The second set of three characters represent the read, write, and

execution rights of the file's owner.
The next three represent the rights of the file's group.
The final three represent the rights granted to everybody else.
----
less [text_file]
to view text files one page at a time.

Page Up or b: Scroll back one page
Page Down or space: Scroll forward one page
q: to exit
G: Go to the end of the text file
1G:Go to the beginning of the text file
/characters: Search forward in the text file for an occurrence of

the specified characters
n: Repeat the previous search
h: Display a complete list less commands and options
----
file [name_of_file]
to determine what kind of data a file contains

No comments:

Post a Comment