du

前言

du 、df 、sort 常常一起结合使用

正文

df

  • df -h
<!-- -h, --human-readable  print sizes in human readable format (e.g., 1K 234M 2G) -->

iPhone:/private/var/MobileAsset/Assets root# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/disk0s1s1  3.8G  3.5G  278M  93% /
devfs            52K   52K     0 100% /dev
/dev/disk0s1s2   26G  2.0G   24G   8% /private/var
/dev/disk4      236M   69M  167M  30% /Developer

 这个参数和sort 的-h 参数意义是一样的
 
  • df -m
iPhone:/var/Keychains root# df -m
Filesystem     1M-blocks  Used Available Use% Mounted on
/dev/disk0s1s1      3644  3397       211  95% /
devfs                  1     1         0 100% /dev
/dev/disk0s1s2     26597  2058     24540   8% /private/var
/dev/disk4           236    69       167  30% /Developer

du

  • which are the larger caches.
In the terminal run du -s /Library/Caches/* | sort -n
  • du -sh *
iPhone:~/Library/Caches root# du -sh * |sort -hr
87M	com.apple.coresymbolicationd
46M	com.apple.pipelined
20M	locationd
1.2M	Backup

cleanSqlite

  • cleanKeychainsSqlite — 简单的方法抽取,更多信息请看see also
//新增/var/Keychains/keychain-2.db
static
void cleanKeychainsSqlite() {
    
    sqlite3 *database;
    
    int openResult = sqlite3_open("/var/Keychains/keychain-2.db", &database);
    if (openResult == SQLITE_OK)
    {
        int execResult = sqlite3_exec(database, "DELETE FROM genp WHERE agrp<>'apple'", NULL, NULL, NULL);
        if (execResult != SQLITE_OK) NSLog(@"kniosre: Failed to exec DELETE FROM genp WHERE agrp<>'apple', error %d", execResult);
        
        execResult = sqlite3_exec(database, "DELETE FROM cert WHERE agrp<>'lockdown-identities'", NULL, NULL, NULL);
        if (execResult != SQLITE_OK) NSLog(@"kniosre: Failed to exec DELETE FROM cert WHERE agrp<>'lockdown-identities', error %d", execResult);
        
        execResult = sqlite3_exec(database, "DELETE FROM keys WHERE agrp<>'lockdown-identities'", NULL, NULL, NULL);
        if (execResult != SQLITE_OK) NSLog(@"kniosre: Failed to exec DELETE FROM keys WHERE agrp<>'lockdown-identities'', error %d", execResult);
        
        execResult = sqlite3_exec(database, "DELETE FROM inet", NULL, NULL, NULL);
        if (execResult != SQLITE_OK) NSLog(@"kniosre: Failed to exec DELETE FROM inet, error %d", execResult);
        
        execResult = sqlite3_exec(database, "DELETE FROM sqlite_sequence", NULL, NULL, NULL);
        if (execResult != SQLITE_OK) NSLog(@"kniosre: Failed to exec DELETE FROM sqlite_sequence, error %d", execResult);
        
        sqlite3_close(database);
    }
    else{
        NSLog(@"knkniosre: Failed to open /var/Keychains/keychain-2.db, error %d", openResult);
        return;
    }

}



see also


        // Delete cookies,  这些在iOS10 基本用不上
        [fileManager removeItemAtPath:@"/var/mobile/Library/Cookies/Cookies.binarycookies" error:nil];
        [fileManager removeItemAtPath:@"/private/var/root/Library/Cookies/Cookies.binarycookies" error:nil];
        [fileManager removeItemAtPath:@"/var/mobile/Library/Safari/History.plist" error:nil];
        [fileManager removeItemAtPath:@"/var/mobile/Library/Safari/SuspendState.plist" error:nil];

<!-- iPhone:/var/Keychains root# du -sh * |sort -hr -->
25M	keychain-2.db

        sqlite3 *database;
        int openResult = sqlite3_open("/var/Keychains/keychain-2.db", &database);
        if (openResult == SQLITE_OK)
        {
                int execResult = sqlite3_exec(database, "DELETE FROM genp WHERE agrp<>'apple'", NULL, NULL, NULL);
                if (execResult != SQLITE_OK) NSLog(@"kniosre: Failed to exec DELETE FROM genp WHERE agrp<>'apple', error %d", execResult);

                execResult = sqlite3_exec(database, "DELETE FROM cert WHERE agrp<>'lockdown-identities'", NULL, NULL, NULL);
                if (execResult != SQLITE_OK) NSLog(@"kniosre: Failed to exec DELETE FROM cert WHERE agrp<>'lockdown-identities', error %d", execResult);

                execResult = sqlite3_exec(database, "DELETE FROM keys WHERE agrp<>'lockdown-identities'", NULL, NULL, NULL);
                if (execResult != SQLITE_OK) NSLog(@"kniosre: Failed to exec DELETE FROM keys WHERE agrp<>'lockdown-identities'', error %d", execResult);

                execResult = sqlite3_exec(database, "DELETE FROM inet", NULL, NULL, NULL);
                if (execResult != SQLITE_OK) NSLog(@"kniosre: Failed to exec DELETE FROM inet, error %d", execResult);

                execResult = sqlite3_exec(database, "DELETE FROM sqlite_sequence", NULL, NULL, NULL);
                if (execResult != SQLITE_OK) NSLog(@"kniosre: Failed to exec DELETE FROM sqlite_sequence, error %d", execResult);

                sqlite3_close(database);
        }
        else NSLog(@"kniosre: Failed to open /var/Keychains/keychain-2.db, error %d", openResult);



转载请注明: > du

在操作过程或者文章有问题的话欢迎在 原文 里提问或指正。

赞赏支持

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码支持
扫码打赏,你说多少就多少
最近的文章

SBWiFiManager

前言 采用MobileWiFi.framework实现 的背景 实现Associate to wifi的,在iOS 版本10 之后,就比较困难,因为苹果将SBWiFiManager 的joinNetwork:password: 移除掉; 且在iOS10 中SBWiFiManager 的t_manager、t_device、t_currentNetwork 均采用 struct存储,提高了安全性。 因此要实现自动 Associate to wifi 的话,我从hopper 中看...…

iOSre继续阅读
更早的文章

SystemIsUnavailable

前言 用peopen替换system 使用posix_spawn替代system 正文 : ‘system’ is unavailable: not available on iOS 使用FILE *popen(const char *, const char *) __DARWIN_ALIAS_STARTING(__MAC_10_6, __IPHONE_2_0, __DARWIN_ALIAS(popen)) __swift_unavailable_o...…

iOSre继续阅读
更多