الأحد، 29 ديسمبر 2013

دليل الأوامر لـ Mobile Terminal

so going to start out with how to become root and everything in this guide will be as root user unless mentioned otherwise.. everything in ' ' is what to type, dont type the ' ' so if i say 'dpkg' just type dpkg..get it? theres a list of most commands at bottom.. the commands you have depend whats installed in cydia... this is going to be a work in progress guide as im not going to sit here for hours and do it all at once...

ADDED command --help menus for some commands.. get help in terminal by adding --help to most commands.. except apt-get is -h for some reason.. so for help on how to use the commands

'dpkg --help'
'grep --help'
'apt-get -h'




become root user

'su' then will ask for a password and the default password is alpine
'alpine' your not going to see the letters just type it and hit return

then your going to want to change you password so your gona type
'passwd' and then enter the new password you want (you wont see it as you type) and then confirm

apt-get

Usage: apt-get [options] command
apt-get [options] install|remove pkg1 [pkg2 ...]
apt-get [options] source pkg1 [pkg2 ...]

apt-get is a simple command line interface for downloading and
installing packages. The most frequently used commands are update
and install.

Commands:
update - Retrieve new lists of packages
upgrade - Perform an upgrade
install - Install new packages (pkg is libc6 not libc6.deb)
remove - Remove packages
autoremove - Remove automatically all unused packages
purge - Remove packages and config files
source - Download source archives
build-dep - Configure build-dependencies for source packages
dist-upgrade - Distribution upgrade, see apt-get(8)
dselect-upgrade - Follow dselect selections
clean - Erase downloaded archive files
autoclean - Erase old downloaded archive files
check - Verify that there are no broken dependencies

Options:
-h This help text.
-q Loggable output - no progress indicator
-qq No output except for errors
-d Download only - do NOT install or unpack archives
-s No-act. Perform ordering simulation
-y Assume Yes to all queries and do not prompt
-f Attempt to correct a system with broken dependencies in place


EXAMPLES

Spoiler


'apt-get update'
[updates your cydia packages and sources]

'apt-get upgrade'
[installs any available upgrade]

'apt-get install com.sull.sysclean'
[installs a package]

'apt-get remove com.sull.sysclean'
[removes installed package]

'apt-get autoremove'
to remove packages that were installed as a dependancy for a package you have removed.. say you installed installous.. it installed appsync
automaticlly but when you remove installous it doesnt remove appsync with it.. this command finds all those left behind packages no longer needed

'apt-get autoclean' or 'apt-get clean'
to clean out archived packages downloaded from cydia



dpkg

Usage: dpkg [<option> ...] <command>

Commands:
-i|--install <.deb file name> ... | -R|--recursive <directory> ...
--unpack <.deb file name> ... | -R|--recursive <directory> ...
-A|--record-avail <.deb file name> ... | -R|--recursive <directory> ...
--configure <package> ... | -a|--pending
--triggers-only <package> ... | -a|--pending
-r|--remove <package> ... | -a|--pending
-P|--purge <package> ... | -a|--pending
--get-selections [<pattern> ...] Get list of selections to stdout.
--set-selections Set package selections from stdin.
--clear-selections Deselect every non-essential package.
--update-avail <Packages-file> Replace available packages info.
--merge-avail <Packages-file> Merge with info from file.
--clear-avail Erase existing available info.
--forget-old-unavail Forget uninstalled unavailable pkgs.
-s|--status <package> ... Display package status details.
-p|--print-avail <package> ... Display available version details.
-L|--listfiles <package> ... List files `owned' by package(s).
-l|--list [<pattern> ...] List packages concisely.
-S|--search <pattern> ... Find package(s) owning file(s).
-C|--audit Check for broken package(s).
--print-architecture Print dpkg architecture.
--compare-versions <a> <op> <b> Compare version numbers - see below.
--force-help Show help on forcing.
-Dh|--debug=help Show help on debugging.

-h|--help Show this help message.
--version Show the version.
--license|--licence Show the copyright licensing terms.

Use dpkg -b|--build|-c|--contents|-e|--control|-I|--info|-f|--field|
-x|--extract|-X|--vextract|--fsys-tarfile on archives (type dpkg-deb --help).



Spoiler

heres some examples.

'dpkg -i /var/root/sysclean.deb'
installs a package. use full file path to location and the actual name of the deb file.

'dpkg -r com.sull.sysclean'
uninstalls deb. this uses the package name. the name you see at the bottom of descripion in cydia


'dpkg -P'
purges configuration files for uninstalled packages. some packes after uninstalling you will still see in terminal as deinstalled. those packages still have files left behind. not exactly sure what those may be but ive had uninstalled packages still causing issues until i ran dpkg -P. same usage as dpkg -r

'dpkg --get-selections'
will list all packages currently installed in cydia and their status

'dpkg -L com.sull.sysclean'
will list all files that were installed by that package

'dpkg -S'
then the path to a file and will tell you what package instlled it. ex if you find the file sysclean and want to know what installed it type
'dpkg -S /usr/bin/sysclean' ( then terminal would say) com.sull.sysclean


'dpkg -$ --force-all'
i used $ for all dpkg options.. could be -r, -s, -i whatever.. if dpkg give you an error use --force-all to make it do what you want even if it breaks something..dont use this unless you have a good idea what ur doing

'dpkg -b /var/folders/myfirstdeb'
builds a deb.. if you want to make your own debian package this is the command to build it. to much to explain on that so if your interested go to the guide sull has already made here http://insanelyi.com...dpost__p__15830

thats most of the basic the dpkg commands.. so heres some simple use commands


Settings Permissions


Spoiler

'chmod'
changes permission for files.. if you want to change 1 file just use the path to the 1 file or folder.. if its folder it will not change the permissions of files inside.. for that you would need to use -R option for apply recursively.. same rules apply for the next 2 commands..ex

'chmod 0755 /var/folders/file.txt' ------changes permissions for that 1 file

chmod -R 0755 /var/folders' -------------changes permissions for folder and everything inside

'chown'
changes owner and group of files and folders.. same usage as chmod.. if your not familiar with them you may get confused between the 2.. i remember by "chown" will CHange OWNer and the other one does the other thing..

'chown root:wheel /var/folders'

'chown -R root:wheel /var/folders'


----how to list files, read files, write files-----------

Spoiler

ls (thats lower case LS) is for list...should be pretty easy to know wh
at that does

'ls /var/root'------------- will list everything you see in /var/root directory. "Media | Library"

'ls -R /var/root' ---------will list everything in /var/root recursivley.. all files in every folder. it will keep going till theres nothing unmentioned left this next option works all through out terminal..its '>' the way im using it i think of as a funnel taking what evers infront of it and funneling it all into a file... can also mean "more than, less than ect" so

'ls /var/root > /var/root/rootlist.txt'
will make a list of whats in /var/root and make it a file so now you have /var/root/rootlist.txt and
if you want to read the file from terminal use the command 'cat'

'cat /var/root/rootlist.txt'

and will output something like
-------------------------------------
Library
Media

------------------------------------

if you want to write something into a file use 'echo' like

'echo "I like Big tittys" >Titty.txt'

then you can read it with

'cat Titty.txt'
would return -> "I like Big Tittys"

using 1 > when piping to a file will overwrite whatever was already there.. 2 >> will append to the end of the file.. so it i did

'echo "a whole bunch!" >>Titty.txt'

then i

'cat Titty.txt'
now would say

"I Like Big Tittys
a whole bunch!"

if i just used 1 > and did

echo "a whole bunch!" >Titty.txt'

then

'cat Titty.txt'

would return only

"a whole bunch!"


Respring, Reboot---- and some Springboard settings------------------
Spoiler

'respring' -------------------do i need to explain what this does? if your here and are really about to ask, dont cuz i will make fun of you and tell you to go to the play in the themes section

'killall SpringBoard' ------does samething

'sbreload' -------------------does a little differently it shuts down processes first more like a how a computer shuts down.. not sure if theres any significants to that or not..

'reboot' -----if your still here refer to 'respring' comment ^^^^

------------------------------------------------------------------------------------

'sb -l' thats sb -L (little L)
lists all your sbringboard settings..

'sb -s brc0703 SBFakeCarrier' ---- sets your carrier to brc0703..up to 4.1 only

'sb -1 SBDontLockEver' ---- device will never fall asleep or go to lock screen.. use -0 to disable instead of -1

'sb -1 SBDisableMailAutoLaunch' ---- stops mail from running in background

'sb -1 SBHideACPower' ---- device doesnt do anything when connected to power.. still charges just no vibrate or signs




apt-cache
Spoiler

freakin A i just added a tonm of crap and accidently hit the damn signature image and took me to a new page and erased everything..FML


'apt-cache'
cydia apt cache database... package info

'apt-cache pkgnames'
will display all pacakges cydia has every seen.. way to long a list to run alone..use grep to specify what ur lookin for

'apt-cache pkgnames | grep barrel'
search all pacakges but only display lines that have barrel in it

'apt-cache pkgnames | grep sull'
display all lines with sull... basicly all insanelyi's packages.. to count them use -c

'apt-cache pkgnames | grep -c sull'
will count all pacakges with sull in the name


ADDING MORE 7/2/11

freakin sweet just found a way to display all pacakges from a certain Author..

'apt-cache show `apt-cache pkgnames com.sull` | grep -A3 -B3 'Author: brc0703'

ok 'apt-cache show' will show info for a pacakge. 'apt-cache pkgnames com.sull' will output all pacakges that start with com.sull.. putting ` ` around `apt-cache pkgnames com.sull` is telling 'apt-cache show' to show pacakge info for the output of 'apt-cache pkgnames com.sull' which is all insanelyi pacakge.. then using grep Author: brc0703 will only show lines with Author: brc0703 in them and adding -A3 shows the next 3 lines after match and -B3 shows 3 lines before match..

hope that wasnt to confusing..



-----------------------------------------------------------------------------------------------------------------------

'gssc'
display a ton of info about your device..

'locate'
will search your device for what ever you tell it

'locate icon'
will locate and display the path to everything that has icon in the name

'locate icon | grep Themes'
display path to all icons but have to have Themes in the path line... if you ran themes(lower case) it probably woudnt show anything..would use -i to ignoes case diff

'locate icon | grep -i themes'
wouldnt matter if Themes or themes

...thats all for now clicking that stupid sig wasted a ton of time lol.. ill try to add more later..



..well this is taking longer than i expected.. only dont with apt and i wanna quit.. so ill add more later to this.. give suggestions on what commands you want me to explain and if i know ill add it to the guide..


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

grep filter stdout for lines containing expression   (only shows that have the word you want )
Spoiler
going to be using a little bit more complicated terminal commands here..



Usage: grep [OPTION]... PATTERN [FILE]...
Search for PATTERN in each FILE or standard input.
PATTERN is, by default, a basic regular expression (BRE).
Example: grep -i 'hello world' menu.h main.c

Regexp selection and interpretation:
-E, --extended-regexp PATTERN is an extended regular expression (ERE)
-F, --fixed-strings PATTERN is a set of newline-separated fixed strings
-G, --basic-regexp PATTERN is a basic regular expression (BRE)
-P, --perl-regexp PATTERN is a Perl regular expression
-e, --regexp=PATTERN use PATTERN for matching
-f, --file=FILE obtain PATTERN from FILE
-i, --ignore-case ignore case distinctions
-w, --word-regexp force PATTERN to match only whole words
-x, --line-regexp force PATTERN to match only whole lines
-z, --null-data a data line ends in 0 byte, not newline

Miscellaneous:
-s, --no-messages suppress error messages
-v, --invert-match select non-matching lines

Output control:
-m, --max-count=NUM stop after NUM matches
-n, --line-number print line number with output lines
--line-buffered flush output on every line
-H, --with-filename print the filename for each match
-h, --no-filename suppress the prefixing filename on output
--label=LABEL print LABEL as filename for standard input
-o, --only-matching show only the part of a line matching PATTERN
-q, --quiet, --silent suppress all normal output
--binary-files=TYPE assume that binary files are TYPE;
TYPE is `binary', `text', or `without-match'
-R, -r, --recursive equivalent to --directories=recurse
--include=FILE_PATTERN search only files that match FILE_PATTERN
--exclude=FILE_PATTERN skip files and directories matching FILE_PATTERN
--exclude-from=FILE skip files matching any file pattern from FILE
--exclude-dir=PATTERN directories that match PATTERN will be skipped.
-L, --files-without-match print only names of FILEs containing no match
-l, --files-with-matches print only names of FILEs containing matches
-c, --count print only a count of matching lines per FILE

Context control:
-B, --before-context=NUM print NUM lines of leading context
-A, --after-context=NUM print NUM lines of trailing context
-C, --context=NUM print NUM lines of output context
-NUM same as --context=NUM

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


Usage: find [path...] [expression]

default path is the current directory; default expression is -print
expression may consist of: operators, options, tests, and actions:

operators (decreasing precedence; -and is implicit where no others are given):
( EXPR ) ! EXPR -not EXPR EXPR1 -a EXPR2 EXPR1 -and EXPR2
EXPR1 -o EXPR2 EXPR1 -or EXPR2 EXPR1 , EXPR2

positional options (always true): -daystart -follow -regextype

normal options (always true, specified before other expressions):
-depth --help -maxdepth LEVELS -mindepth LEVELS -mount -noleaf
--version -xdev -ignore_readdir_race -noignore_readdir_race

tests (N can be +N or -N or N): -amin N -anewer FILE -atime N -cmin N
-cnewer FILE -ctime N -empty -false -fstype TYPE -gid N -group NAME
-ilname PATTERN -iname PATTERN -inum N -iwholename PATTERN -iregex PATTERN
-links N -lname PATTERN -mmin N -mtime N -name PATTERN -newer FILE
-nouser -nogroup -path PATTERN -perm [+-]MODE -regex PATTERN
-wholename PATTERN -size N[bcwkMG] -true -type [bcdpflsD] -uid N
-used N -user NAME -xtype [bcdpfls]


EXAMPLES

'find / -cmin -30'
find all files in / created in less than 30 min..

'find /private/var/mobile/Documents -amin 50'
find all files in /private/var/mobile/Documents accessed in less than 50 min

PID

heres a script i made up for showing process ids.. ill explain the best i can
lines with that start with # are not read by the script they are only notes for readers..
all except the first #!


Spoiler







now "ps -ef | grep -i $1 | grep -v grep | grep -v pid | sed 's/\//\ /g' | awk '{ print $2, $NF }" is several commands
start by noticing the | .... each one seperates a command leaving its value to be fed to the next
so ps -ef outputs a lot of processes in columns with a bunch of info(see img below)
now grep is going to pick out only lines that have $1(whatever the user typed) and -i tells grep to ignore case..
grep -v means ignore so -v grep is saying ignore itself.. dont pick its own process.. same with grep -v pid.. ignore pid process(itself)
im not real familiar with sed.. i just know that sed 's/what ever is here/gets replaced with whats here/g'..
the \ tell it that the next / are supposed to be acknowledged and not that its supposed to continue on in the command
so if i did sed's////g' its gona error cuz thats too many / but sed 's/\// says the / following \ is the input charachter so
sed 's/\/\ /g' is replacing all the / with a blank space.. no we already filtered out only lines with the users search term
now awk '{ print $2, $NF } is saying print the second word and last word of the chosen lines.. so as seen below there are multiple columns
awk is saying only read the second and last of each line.. and we already filtered out only lines that match the user input
the reasom for replacing / with a blank space is so awk will only print the last name of the path not the whole path.. cuz if
it was /usr/bin/pid it would read the whole thing as one word but usr bin pid it only reads pid. so the final result is
processes id and process and would output like
145 MobilePhone


[color=red]Loop, How to modify multiple files
first your going to figure out what it is you want changed.. we will use a bunch of ROMs that you want to zip individually..
so your going to set a variable to the list of targets.. then the use of 'for line in `targets` do "something" and its going to go line by line performing the task on each one..so this exapmle would be

for line in $(ls /var/mobile/Media/ROMs/GENESIS | grep -v zip)
do
zip "$line".zip "$line"
done


hope that helps a little with understanding how things run together
heres a list of commands on my phone.. your list will be different cuz it depends what you have installed.. and i have somr custom ones in there.. i took most of them out so not to get confused looking for something in cydia



brc0703:~ root#
Display all 631 possibilities? (y or n)
! env mount sha256sum
./ envsubst mount_cd9660 sha384sum
2xrm error mount_devfs sha512sum
7z esac mount_fdesc shc
7za eval mount_hfs shift
: exec mount_kernfs shopt
BTServer exit mount_msdos shred
BTdaemon expand mount_null shuf
BlueTool export mount_procfs sid
BlueToolH4 expr mount_synthfs simulatecrash
DumpBasebandCrash ezrestore mount_union size
PatchBlueTool ezsave msgattrib slattach
SpringBoardAccess-test factor msgcat sleep
[ fairplayd.N88 msgcmp slogin
[[ fairplayd.default msgcomm sms
]] false msgconv sort
abquery fc msgen sorted
abs fdisk msgexec source
ac fg msgfilter split
accessoryd fgrep msgfmt sqlite3
accton fi msggrep ssh
alias file msginit ssh-add
allmyi find msgmerge ssh-agent
aosnotifyd findme msgunfmt ssh-keygen
ap2ipa finger msguniq ssh-keyscan
apmode fmf mso sshd
appSearch fmt mv startupfiletool
appdub fold nano stat
appnum for natd strings
appsearch freemem ncat strip
apt-cache fsck ncurses5-config stty
apt-cdrom fsck_hfs ncursesw5-config su
apt-config fsck_msdos ndiff sudo
apt-extracttemplates fstyp ndp sudoedit
apt-ftparchive fstyp_hfs netstat sum
apt-get fstyp_msdos newfs suspend
apt-key fstyp_ntfs newfs_hfs sw_vers
apt-mark fstyp_udf newfs_msdos sync
apt-sortpkgs fstyp_ufs ngettext syschk
ar ftp nice sysctl
arch function nl syslogd
arm-apple-darwin9-c++ funzip nm tabs
arm-apple-darwin9-g++ g++ nmap tac
arm-apple-darwin9-gcc gawk nmapfe tail
arm-apple-darwin9-gcc-4.2.1 gcc nmedit talk
arp gccbug node tar
as gcov node-waf tee
athief getconf nohup telnet
athief.sh getdeviceinfo nologin test
autopoint getopts notificationWatcher tftp
autossh gettext notify then
awd_ice2 gettext.sh notifyd tic
awk gettextize nping time
backup getty nproc timeout
badge geturl nvram times
badgenum gpg od toe
base64 gpg-zip openURL top
basename gpgsplit openssl touch
bash gpgv otool tput
bashbug gremlind otool64 tr
bg grep pagesize traceroute
bid groups pagestuff traceroute6
bind gssc passwd trap
break gunzip paste trpt
builtin gzexe patchsync true
bunzip2 gzip pathchk truncate
bzcat halt pax tset
bzip2 hash pbcopy tsort
bzip2recover head pbpaste tty
c++ help pcap-config tunefs
c_rehash hexdump pcre-config tweet
caller hidelibconvert pcregrep type
captoinfo history pcretest typeset
case hostid pfctl uicache
cat hostinfo photofix uiduid
cd hostname pid uiopen
chcon id pincrush uishoot
checksyms if ping ulimit
chflags ifconfig ping6 umask
chgrp igawk pinky umount
chmod iis pkglist unalias
chown in play uname
chroot indr plutil uncompress
cksum infocmp pmset unexpand
clear infotocap popd unifdef
clri inquiry powerlog uninstall_zenmap
cmp install pppd uniq
cms install_name_tool pr unlink
codesign_allocate intelliStatusIcons printenv unlzma
comm ioalloccount printf unrar
command ioclasscount ps unset
compgen ioreg ptx until
compiler iostat punchd unxz
complete ip-print pushd unzip
compopt ip6conf pwd unzipsfx
compress ip6fw pwd_mkdb update
continue ipconfig quitTop updatedb
coproc ipcrm quot uptime
cp ipcs quota urlclip
cpp ipfw quotacheck users
csplit itmsSearch quotaon uudecode
ctags jobs racoon uuencode
cunt join racoonctl uuid
curl kill ranlib uuid-config
curl-config killall rcp vdir
cut lang2.2 read vibrate
cycc lang2ez readarray vifs
cyfix last readlink vipw
cymanage launch readonly visudo
daily launchctl reboot vm_stat
date launchd recAudio vsdbutil
db_archive ld recode-sr-latin wait
db_checkpoint ld64 redo_prebinding wc
db_codegen ld_classic renice wget
db_deadlock ldid repquota which
db_dump let reset while
db_hotbackup libtool respring who
db_load link restart whoami
db_printlog lipo restore whois
db_recover ln return write
db_stat lnc rld xargs
db_upgrade local rlogin xgettext
db_verify locale rm xml2-config
dd locate rmdir xmlcatalog
declare lock rnano xmllint
dev_mkdb logger rootme xnmap
deviceinfo login route xz
df logname routed xzcat
diff logout rpcgen xzcmp
diff3 ls rsh xzdec
dir lsvfs rtadvd xzdiff
dircolors lua rtsol xzegrep
dirname luac run-parts xzfgrep
dirs lzcat runcon xzgrep
disown lzcmp safemode xzless
dmesg lzdiff sb xzmore
do lzegrep sbar yes
done lzfgrep sbdidlaunch zcat
dpkg lzgrep sbreload zcmp
dpkg-deb lzless sbsettingsd zdiff
dpkg-name lzma scp zdump
dpkg-query lzmadec script zegrep
dpkg-split lzmainfo scselect zenmap
dpkg-trigger lzmore scutil zfgrep
dpkg-unpack mDNSResponder sdiff zforce
dselect mDNSResponderHelper securekeyvaultd.N88 zgrep
du main.m sed zic
dump makemyring seg_addr_table zip
dumpfs mapfile seg_hack zipcloak
dynamic_pager md segedit zipnote
echo md5sum select zipsplit
edge mediaserverd seq zless
edgrem mesg set zmore
edquota mkdir sftp znew
egrep mkfifo sgchk zprint
elif mkfile sh {
else mknod sha1sum }
enable mktemp sha224sum
brc0703:~ root#