"use strict";
var __assign = (this && this.__assign) || function () {
    __assign = Object.assign || function(t) {
        for (var s, i = 1, n = arguments.length; i < n; i++) {
            s = arguments[i];
            for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
                t[p] = s[p];
        }
        return t;
    };
    return __assign.apply(this, arguments);
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
var __generator = (this && this.__generator) || function (thisArg, body) {
    var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
    return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
    function verb(n) { return function (v) { return step([n, v]); }; }
    function step(op) {
        if (f) throw new TypeError("Generator is already executing.");
        while (_) try {
            if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
            if (y = 0, t) op = [op[0] & 2, t.value];
            switch (op[0]) {
                case 0: case 1: t = op; break;
                case 4: _.label++; return { value: op[1], done: false };
                case 5: _.label++; y = op[1]; op = [0]; continue;
                case 7: op = _.ops.pop(); _.trys.pop(); continue;
                default:
                    if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
                    if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
                    if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
                    if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
                    if (t[2]) _.ops.pop();
                    _.trys.pop(); continue;
            }
            op = body.call(thisArg, _);
        } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
        if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
    }
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.FullLinuxTerminal = exports.getServerSideProps = void 0;
var jsx_runtime_1 = require("react/jsx-runtime");
var icon_1 = require("@cocalc/frontend/components/icon");
var antd_1 = require("antd");
var code_1 = __importDefault(require("components/landing/code"));
var content_1 = __importDefault(require("components/landing/content"));
var footer_1 = __importDefault(require("components/landing/footer"));
var head_1 = __importDefault(require("components/landing/head"));
var header_1 = __importDefault(require("components/landing/header"));
var info_1 = __importDefault(require("components/landing/info"));
var pitch_1 = __importDefault(require("components/landing/pitch"));
var sign_in_1 = __importDefault(require("components/landing/sign-in"));
var snapshots_1 = __importDefault(require("components/landing/snapshots"));
var A_1 = __importDefault(require("components/misc/A"));
var customize_1 = require("lib/customize");
var with_customize_1 = __importDefault(require("lib/with-customize"));
var cocalc_jupyter_bash_png_1 = __importDefault(require("public/features/cocalc-jupyter-bash.png"));
var cocalc_shell_script_run_png_1 = __importDefault(require("public/features/cocalc-shell-script-run.png"));
var cocalc_terminal_collab_gif_1 = __importDefault(require("public/features/cocalc-terminal-collab.gif"));
var linux_logo_svg_1 = __importDefault(require("public/features/linux-logo.svg"));
var terminal_jupyter_postgresql_png_1 = __importDefault(require("public/features/terminal-jupyter-postgresql.png"));
function Linux(_a) {
    var customize = _a.customize;
    return ((0, jsx_runtime_1.jsxs)(customize_1.Customize, __assign({ value: customize }, { children: [(0, jsx_runtime_1.jsx)(head_1.default, { title: "Online Linux Environment" }), (0, jsx_runtime_1.jsxs)(antd_1.Layout, { children: [(0, jsx_runtime_1.jsx)(header_1.default, { page: "features", subPage: "linux" }), (0, jsx_runtime_1.jsxs)(antd_1.Layout.Content, { children: [(0, jsx_runtime_1.jsx)("div", __assign({ style: { backgroundColor: "#c7d9f5" } }, { children: (0, jsx_runtime_1.jsx)(content_1.default, { startup: "Linux", logo: linux_logo_svg_1.default, title: "Online Linux Environment", subtitle: "Learn Linux and Bash Scripting without messing up your own computer.", subtitleBelow: true, image: cocalc_shell_script_run_png_1.default, alt: "Running a bash script to count in Linux" }) })), (0, jsx_runtime_1.jsx)(FullLinuxTerminal, {}), (0, jsx_runtime_1.jsx)(sign_in_1.default, { startup: "Linux" }), (0, jsx_runtime_1.jsxs)(info_1.default, __assign({ title: "Realtime collaboration", icon: "users", image: cocalc_terminal_collab_gif_1.default, anchor: "a-real-time", alt: "Video showing using vim collaboratively with chat" }, { children: [(0, jsx_runtime_1.jsxs)("p", { children: ["Terminals in CoCalc are represented by files with the extension", " ", (0, jsx_runtime_1.jsx)("code", { children: ".term" }), ". The same terminal can be opened by two or more people simultaneous. Both see the same view, which adaptively resizes to a common size."] }), (0, jsx_runtime_1.jsxs)("p", { children: ["Additionally, you can open a", " ", (0, jsx_runtime_1.jsx)(A_1.default, __assign({ href: "https://doc.cocalc.com/chat.html" }, { children: "chat" })), " panel to exchange thoughts and ideas."] }), (0, jsx_runtime_1.jsxs)("p", { children: ["This is ideal for getting advice from a colleague or", " ", (0, jsx_runtime_1.jsx)(A_1.default, __assign({ href: "https://doc.cocalc.com/teaching-interactions.html" }, { children: "helping one of your students" })), ".", " "] })] })), (0, jsx_runtime_1.jsx)(info_1.default.Heading, __assign({ description: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: ["The following are some additional specific features of Linux Terminals in CoCalc.", (0, jsx_runtime_1.jsx)("br", {}), "There is also more", " ", (0, jsx_runtime_1.jsx)(A_1.default, __assign({ href: "https://doc.cocalc.com/terminal.html" }, { children: "comprehensive documentation" })), "."] }) }, { children: "Feature Overview" })), (0, jsx_runtime_1.jsxs)(info_1.default, __assign({ title: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: ["Run", " ", (0, jsx_runtime_1.jsx)(A_1.default, __assign({ href: "https://en.wikipedia.org/wiki/Bash_(Unix_shell)" }, { children: "Bash" })), " ", "scripts"] }), icon: "terminal", image: cocalc_shell_script_run_png_1.default, caption: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: ["Bash ", (0, jsx_runtime_1.jsx)(code_1.default, { children: "script.sh" }), " file (left),", " ", (0, jsx_runtime_1.jsx)(code_1.default, { children: "bash -f script.sh" }), " to run (right)"] }), anchor: "a-shell-script", alt: "Running a bash script to count in Linux" }, { children: [(0, jsx_runtime_1.jsxs)("p", { children: ["CoCalc's", " ", (0, jsx_runtime_1.jsx)(A_1.default, __assign({ href: "https://doc.cocalc.com/frame-editor.html" }, { children: "code editor" })), " ", "supports", " ", (0, jsx_runtime_1.jsxs)("strong", { children: ["editing a", " ", (0, jsx_runtime_1.jsx)(A_1.default, __assign({ href: "https://www.gnu.org/software/bash/" }, { children: "bash script" })), " ", "side-by-side with a", " ", (0, jsx_runtime_1.jsx)(A_1.default, __assign({ href: "https://doc.cocalc.com/terminal.html" }, { children: "terminal" }))] }), "."] }), (0, jsx_runtime_1.jsxs)("p", { children: ["To get started, create a script file ending with ", (0, jsx_runtime_1.jsx)(code_1.default, { children: ".sh" }), ", for example ", (0, jsx_runtime_1.jsx)(code_1.default, { children: "script.sh" }), ". Opening that file presents you an editor with ", (0, jsx_runtime_1.jsx)("strong", { children: "syntax highlighting" }), ". Then click the ", (0, jsx_runtime_1.jsx)(code_1.default, { children: "Shell" }), " button to open up a Terminal and type in", " ", (0, jsx_runtime_1.jsx)(code_1.default, { children: "bash -f script.sh" }), " to run your script."] }), (0, jsx_runtime_1.jsxs)("p", { children: ["This helps you learning Bash by exploring its commands directly in your browser and immediately experiencing the results.", " "] })] })), (0, jsx_runtime_1.jsxs)(info_1.default, __assign({ title: "Jupyter Bash kernel", image: cocalc_jupyter_bash_png_1.default, icon: "ipynb", anchor: "a-jupyter", alt: "Using Bash via a Jupyter notebook" }, { children: [(0, jsx_runtime_1.jsxs)("p", { children: ["Are you looking for something beyond a terminal or editing shell scripts? CoCalc also offers", " ", (0, jsx_runtime_1.jsxs)("strong", { children: [(0, jsx_runtime_1.jsx)(A_1.default, __assign({ href: "/features/jupyter-notebook" }, { children: "Jupyter Notebooks" })), " ", "running the", " ", (0, jsx_runtime_1.jsx)(A_1.default, __assign({ href: "https://github.com/takluyver/bash_kernel" }, { children: "bash kernel" }))] }), "."] }), (0, jsx_runtime_1.jsx)("p", { children: "This is similar to working with a terminal, but it saves all the input you typed and the corresponding output in \"cells\". That helps you with learning Linux commands, because it makes it easier to edit the code input or compare different outcomes of similar code. Besides that, you can also take notes between code cells." })] })), (0, jsx_runtime_1.jsxs)(snapshots_1.default, { children: [(0, jsx_runtime_1.jsxs)("p", { children: ["The CoCalc terminal is ideal for", " ", (0, jsx_runtime_1.jsx)("strong", { children: "teaching and learning Linux" }), ", because when you make a mistake, it has your back!"] }), (0, jsx_runtime_1.jsx)("p", { children: "Everything runs remotely on CoCalc's servers. This means you do not have to worry about messing up your own computer, dealing with setup and installation issues yourself, or fear losing or corrupting files on your computer." })] }), (0, jsx_runtime_1.jsxs)(info_1.default, __assign({ title: "Databases (PostgreSQL, MySQL, SQLite)", image: terminal_jupyter_postgresql_png_1.default, icon: "database", anchor: "a-database", wide: true, alt: "Using a PostgreSQL database via a terminal and a Jupyter notebook" }, { children: [(0, jsx_runtime_1.jsxs)("p", { children: [(0, jsx_runtime_1.jsx)("strong", { children: "CoCalc supports running various databases inside a project." }), " ", "They run in the same protected networking environment as all other processes in a project. This is ideal for", " ", (0, jsx_runtime_1.jsx)("strong", { children: "learning SQL" }), " or", " ", (0, jsx_runtime_1.jsx)("strong", { children: "persistently storing data" }), " as a result of your computations."] }), (0, jsx_runtime_1.jsxs)("p", { children: [(0, jsx_runtime_1.jsx)("strong", { children: "PostgreSQL" }), ": read", " ", (0, jsx_runtime_1.jsx)(A_1.default, __assign({ href: "https://doc.cocalc.com/howto/postgresql.html" }, { children: "our guide" })), " ", "to get started."] }), (0, jsx_runtime_1.jsxs)("p", { children: ["Besides", " ", (0, jsx_runtime_1.jsx)(A_1.default, __assign({ href: "https://https://www.postgresql.org/" }, { children: "PostgreSQL" })), ", CoCalc also supports ", (0, jsx_runtime_1.jsx)(A_1.default, __assign({ href: "https://www.mysql.com/" }, { children: "MySQL" })), " ", "and ", (0, jsx_runtime_1.jsx)(A_1.default, __assign({ href: "https://sqlite.org" }, { children: "SQLite" })), "."] }), (0, jsx_runtime_1.jsxs)("p", { children: ["To interact with the databases, CoCalc", " ", (0, jsx_runtime_1.jsx)("strong", { children: "pre-installs suitable Python and R libraries" }), " for your convenience."] }), (0, jsx_runtime_1.jsxs)("p", { children: ["In the screenshot, you can see how a PostgreSQL database was setup and started in the first terminal. In the second terminal,", " ", (0, jsx_runtime_1.jsx)(code_1.default, { children: "psql" }), " is used to connect to it and create a table and insert data. Finally, the", " ", (0, jsx_runtime_1.jsx)(A_1.default, __assign({ href: "/features/jupyter-notebook" }, { children: "Jupyter Notebook" })), " on the left connects via the", " ", (0, jsx_runtime_1.jsx)(A_1.default, __assign({ href: "http://initd.org/psycopg/docs/" }, { children: "psycopg2" })), " library and issues a query to the database!"] })] })), (0, jsx_runtime_1.jsx)(sign_in_1.default, { startup: "Linux" })] }), (0, jsx_runtime_1.jsx)(footer_1.default, {})] })] })));
}
exports.default = Linux;
function getServerSideProps(context) {
    return __awaiter(this, void 0, void 0, function () {
        return __generator(this, function (_a) {
            switch (_a.label) {
                case 0: return [4 /*yield*/, (0, with_customize_1.default)({ context: context })];
                case 1: return [2 /*return*/, _a.sent()];
            }
        });
    });
}
exports.getServerSideProps = getServerSideProps;
function FullLinuxTerminal() {
    return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(pitch_1.default, { col1: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("h2", { children: "Full Linux Terminal" }), (0, jsx_runtime_1.jsx)("p", { children: (0, jsx_runtime_1.jsxs)("strong", { children: ["CoCalc offers a full, collaborative, real-time synchronized", " ", (0, jsx_runtime_1.jsx)(A_1.default, __assign({ href: "https://en.wikipedia.org/wiki/Linux" }, { children: "Linux" })), " ", (0, jsx_runtime_1.jsx)(A_1.default, __assign({ href: "https://en.wikipedia.org/wiki/Command-line_interface" }, { children: "Command Line Terminal" })), " ", "in your browser."] }) }), (0, jsx_runtime_1.jsxs)("p", { children: ["Take a look at our", " ", (0, jsx_runtime_1.jsx)("strong", { children: (0, jsx_runtime_1.jsx)(A_1.default, __assign({ href: "https://doc.cocalc.com/terminal.html" }, { children: "terminal documentation" })) }), " ", "to learn more about it!"] }), (0, jsx_runtime_1.jsxs)("p", { children: ["Browse the", " ", (0, jsx_runtime_1.jsx)("strong", { children: (0, jsx_runtime_1.jsx)(A_1.default, __assign({ href: "/software/executables" }, { children: "installed software" })) }), " ", "in CoCalc."] }), (0, jsx_runtime_1.jsxs)("p", { children: ["CoCalc is made for", " ", (0, jsx_runtime_1.jsx)("strong", { children: (0, jsx_runtime_1.jsx)(A_1.default, __assign({ href: "/features/teaching" }, { children: "teaching a course" })) }), ": students just have to sign in to get started!", " "] })] }), col2: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("h2", { children: "Benefits of working 100% online" }), (0, jsx_runtime_1.jsxs)("ul", { children: [(0, jsx_runtime_1.jsxs)("li", { children: ["You no longer have to ", (0, jsx_runtime_1.jsx)("strong", { children: "install and maintain" }), " any software."] }), (0, jsx_runtime_1.jsxs)("li", { children: ["It is possible for multiple people to", " ", (0, jsx_runtime_1.jsx)("strong", { children: "collaboratively use the same terminal in realtime" }), "."] }), (0, jsx_runtime_1.jsx)("li", { children: "You can also edit and run shell script files." }), (0, jsx_runtime_1.jsxs)("li", { children: ["Use", " ", (0, jsx_runtime_1.jsx)("strong", { children: (0, jsx_runtime_1.jsx)(A_1.default, __assign({ href: "https://doc.cocalc.com/chat.html" }, { children: "chat" })) }), " ", "next to the Terminal to discuss your commands with others."] }), (0, jsx_runtime_1.jsxs)("li", { children: [(0, jsx_runtime_1.jsx)("strong", { children: "Automatic backup" }), " keeps your files safe!"] }), (0, jsx_runtime_1.jsxs)("li", { children: ["You can ", (0, jsx_runtime_1.jsx)("strong", { children: "copy and paste" }), " between your local desktop and the online terminal."] })] })] }) }), (0, jsx_runtime_1.jsx)(pitch_1.default, { ext: "sh", col1: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)("h2", { children: [(0, jsx_runtime_1.jsx)(icon_1.Icon, { name: "user-check" }), " What you ", (0, jsx_runtime_1.jsx)("strong", { children: "can" }), " do ..."] }), (0, jsx_runtime_1.jsxs)("ul", { children: [(0, jsx_runtime_1.jsx)("li", { children: "Learn Bash scripting" }), (0, jsx_runtime_1.jsx)("li", { children: "Learn how to use the Linux command line" }), (0, jsx_runtime_1.jsxs)("li", { children: ["Run scripts written in", " ", (0, jsx_runtime_1.jsx)("strong", { children: "Python, R, PHP, Ruby, Go, Perl, Nodejs " }), " etc."] }), (0, jsx_runtime_1.jsxs)("li", { children: ["Compile programs written in", " ", (0, jsx_runtime_1.jsx)("strong", { children: "C/C++, Java, Rust, Assembly, Fortran, Julia, Zig, Haskell," }), " ", "etc."] }), (0, jsx_runtime_1.jsx)("li", { children: "Process and store datafiles" }), (0, jsx_runtime_1.jsx)("li", { children: "Collaborate" }), (0, jsx_runtime_1.jsx)("li", { children: "Use graphical X11 applications" })] })] }), col2: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)("h2", { children: [(0, jsx_runtime_1.jsx)(icon_1.Icon, { name: "user-slash" }), " ... what you ", (0, jsx_runtime_1.jsx)("strong", { children: "cannot" }), " ", "do."] }), (0, jsx_runtime_1.jsxs)("ul", { children: [(0, jsx_runtime_1.jsxs)("li", { children: [(0, jsx_runtime_1.jsx)("strong", { children: (0, jsx_runtime_1.jsx)("code", { children: "Root" }) }), ": due to how CoCalc works, you cannot have root rights. However, there is a wealth of software", " ", (0, jsx_runtime_1.jsx)(A_1.default, __assign({ href: "/software" }, { children: "already installed" })), ", including both system utilities and packages for specific language environments. Regarding Python, R, Nodejs, and Julia environments, you can", " ", (0, jsx_runtime_1.jsx)(A_1.default, __assign({ href: "https://doc.cocalc.com/howto/index.html" }, { children: "install additional packages in your project" })), ". If something is missing,", " ", (0, jsx_runtime_1.jsx)(A_1.default, __assign({ href: "mailto:help@cocalc.com" }, { children: "please tell us" })), "."] }), (0, jsx_runtime_1.jsxs)("li", { children: [(0, jsx_runtime_1.jsx)("strong", { children: "Communicate with the Internet without buying a license" }), ": if you want to run code to download data from another server or checkout a Git repository \u2013 or just want to support CoCalc \u2013 you need a", " ", (0, jsx_runtime_1.jsx)(A_1.default, __assign({ href: "https://doc.cocalc.com/licenses.html" }, { children: "license" })), " ", "applied to your project. Learn more about the", " ", (0, jsx_runtime_1.jsx)(A_1.default, __assign({ href: "https://doc.cocalc.com/trial.html" }, { children: "Trial Projects" })), " ", "that you can use for free."] }), (0, jsx_runtime_1.jsxs)("li", { children: [(0, jsx_runtime_1.jsx)("strong", { children: "Port forwards:" }), " you cannot forward arbitrary ports over ssh to your local computer. (You ", (0, jsx_runtime_1.jsx)("strong", { children: "CAN" }), " ", (0, jsx_runtime_1.jsx)(A_1.default, __assign({ href: "https://doc.cocalc.com/project-settings.html#ssh-keys" }, { children: "ssh into your project" })), ".)"] })] })] }) })] }));
}
exports.FullLinuxTerminal = FullLinuxTerminal;
//# sourceMappingURL=linux.js.map