Terminale iPhone
The Basic Layout
To navigate the file system and manipulate files there are several useful commands and short cuts. I strongly recommend logging into your iPhone with MobileTerminal or over SSH and following along. When you first log in your current working directory will be your home directory, most likely /var/mobile or /private/var/root depending on what user you logged in as. You can check your working directory with the pwd (present working directory) command.
To see the contents of a directory you use the ls command, which stands for list. Without arguments ls will list most of the contents of the current working directory. What ls doesn’t show you are hidden files. In UNIX any file starting with a . is a hidden file. Hidden files are usually configuration or system files that users don’t normally need to access. I like to be able to see these files so I usually use ls -a. Here is the contents of my home directory.
- ./ - . is the alias for the current directory. “ls -a .” would show us the same last as “ls -a”
- ../ - .. is the alias for the parent directory
- .bash_history - is used by BASH to store every command you type at the command prompt. It is updated when you log out of bash
- .forward - used to forward system mail to /dev/null
- .ssh/ - used by ssh to store your known_hosts file
- Applications/ - where your AppStore applications are stored
- Library/ - preferences and user data are stored here, e.g., voice mail is stored in ~/Library/Voicemail as .amr files
- Media/ - where iTunes media files are stored
The top level of the UNIX file structure is /, which is known as the root directory. You can make the root directory your working directory by using the cd to change directories.
The contents of my root directory are:
- /.Trashes - where trashed files are stored
- /.fseventsd - file system event logs
- /Applications - link to /var/stash/Applications/ where system applications such as MobileSafari and Cydia/Installer applications are stored.
- /Developer - empty on my system, on OS X this is where XCode would be installed.
- /Library - system level application data and preferences are stored here
- /System - the lowest level system files are stored here, on OS X this folder is stored in the boot sector
- /User - a link to ~
- /bin - is where executable files are kept
- /boot - empty on my system
- /cores - empty on my system
- /dev - in UNIX everything is a file, the files in /dev are interfaces to kernel device drivers, e.g., /dev/disk0 is your iPhone’s hard drive, /dev/disk0s1 represents the root partition and /dev/disk0s2 is the partition mounted at /private/var
- /etc - link to /private/etc, where configuration files are kept.
- /lib - where programming libraries are stored
- /mnt - where devices can be mounted
- /private - where /etc /var really live on iphone.
- /sbin - where system and administrative commands are kept
- /tmp - temporary system scratch files
- /usr - where applications are stored
- /var - link to /private/var, where logs and other system files go
Commands
Here are some other basic commands you should familiarize yourself with. All UNIX systems should have a command called man. Man brings up the manual page for any given command. To find out how to use cat you could type “man cat”. Right now iPhone doesn’t support the man command but you can use it in terminal on your desktop. The commands and their options are nearly identical for all UNIX systems.
- cat - used to concatenate and display file contents.
- cd - changes the working directory
- cp - copies files
- ls - lists files
- mkdir - makes directories
- more - page output
- mv - moves files
- pwd - outputs working directory
- rm - removes files and directories
- rmdir - removes empty directories
- touch - changes file access and modification times
Shortcuts
- . - current director
- .. - parent directory
- ~ - home directory of user that is currently logged in.
- ~otheruser - home directory of another user where otheruser is replaced with a real user’s name
0 commenti:
Posta un commento