upgrading xubuntu to 24.04, fresh install, but I’d like to copy the output of both dpkg -l and history to a usb stick.

About history: will it copy all commands I executed on all tabs? I work with several tabs simultaneously.

ETA: thank you for all your input, problem has been solved.

  • bloodfart
    link
    fedilink
    arrow-up
    4
    ·
    edit-2
    6 months ago

    plug in the usb, run the command lsblk. it will list all the block devices that the computer can see.

    look for your usb by size, etc. the column “name” after lsblk will be the device and partition (for example sdc and sdc1). the “name” entry on the same line as your usb’s size with a number after it is the partition, the one without a number is the usb itself. you will be mounting the partition.

    make a directory in /var to mount the usb stick in with mkdir /var/usb. that command writes to the /var section of your filesystem, where /var-iable files live. mount the usb stick at that location with mount /dev/[your partition, like sdc1] /var/usb.

    example: my usb was /dev/sdc1, so for me it’s mount /dev/sdc1 /var/usb. the syntax is mount [device] [location].

    run any command with |tee -i /var/usb/target_filename.txt after it to both output the command to the screen and send it to a file on the usb. that command writes the output of whatever command preceeds it to the specified file in /var/usb.

    example: ls / |tee -i /var/usb/target_filename.txt would write the output of the command “ls /”, listing the contents of the root of your filesystem, to /var/usb/target_filename.txt as well as displaying it. if /ver/usb/target_filesystem.txt doesn’t exist, it will be created.

    use different files on different commands so you don’t write over what you have or pass -a to the tee command so it will -a-ppend the text it writes to the end of the file. ex: |tee -ia /var/usb/filename.txt

    for the specific command you asked about, it would be dpkg -l |tee -i /var/usb/target_filename

    to write out your command history, use the “history” command. it can be given the tee treatment as well. to access a users history look at their $HISTFILE. if you don’t know what interpreter they’re using, assume bash and look for ~/.bash_history